WORD Viewer problem using VBA and VB 6.0

J

Jon Philip

Hello,
I have an interesting problem for the knowledgable vb/vba programmers
out there. I am using VB 6.0 with a reference to the Microsoft Word
8.0 Object Library. I am generating a Word document with VB 6.0 and
opening the document in Word Viewer using the shell command.
Everything works fine, but after the document is open, it takes 3 or 4
clicks on the close(X) button to get the viewer to respond and close.
The same applies when clicking on the file menu within the viewer.
Has anyone experienced this problem that can give me a solution. I
would like experienced responses only. No "guess" answers! Here is
the tail portion of the code: Thanks in advance!

' Insert number of pages into report header
intNumPages = wordApp.ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
wordApp.ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
wordSelection.MoveRight , 10 ' move position to after Page x of
wordSelection.TypeText intNumPages

' Save doc
wordDoc.SaveAs strDocPath
wordDoc.Close
wordApp.Application.Quit

' Destroy objects
Set wordDoc = Nothing
Set wordSelection = Nothing
Set wordApp = Nothing

' Open doc file with Word viewer
strQuotes = """"
lngShell = Shell(strWordPath & strQuotes & strDocPath & strQuotes,
vbNormalFocus)
DoEvents
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top