Solved

give a print preview of the word document

Posted on 1999-01-13
2
194 Views
Last Modified: 2012-05-04
What do i have to do to give a print preview of an existing word document. i´m working with vb5.0 and using word97.

0
Comment
Question by:nimicheck
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 50 total points
ID: 1455969
'Somewhere in a normal VB Module
'For Word interaction
Global g_objWord As Object
---------------------------------------------------

'Wherever you wish to call word
'If Word is not already instantiated, instantiate it now.
If g_objWord Is Nothing Then
    Set g_objWord = CreateObject("Word.Basic")
End If

'Word might have been closed since previous run, catch this error
On Local Error GoTo Err_ExpectedWordErrors:
g_objWord.FileOpen "C:\MyWordFile.Doc"

On Local Error GoTo <Your normal Error Handler>
g_objWord.AppMaximize 1

'Some code here to avoid continuing on into error handlers,
'for example:
Exit Sub

Err_ExpectedWordErrors:
If (Err.Number = 78) Or (Err.Number = 55) Then
    'File not found
    'For example: Exit Sub
End If
If (Err.Number = 70) Then
    'permission denied
    'For example: Exit Sub
End If
'Word may be closed by the user, try to re-instantiate it.
'If anything goes wrong from now on, treat it as any other unexpected error.
On Local Error GoTo <Your normal Error Handler>
Set g_objWord = Nothing
Set g_objWord = CreateObject("Word.Basic")
Resume

<Your normal Error Handler>
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1455970
Note:
The above code will actually open the document, but the good thing is that the user will get the Word interface they are used to and happy with, plus the print option is there for them to choose as usual (Inclusive Print Preview).

Maybe there is an option in Word.Basic to open a document as read only if you wish to do so. Lots of help available when you open Word itself.

Good luck!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now