Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

give a print preview of the word document

Posted on 1999-01-13
2
Medium Priority
?
200 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 150 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

705 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