Solved

give a print preview of the word document

Posted on 1999-01-13
2
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 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