Solved

give a print preview of the word document

Posted on 1999-01-13
2
196 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

820 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