Maximizing Word Ap

craigachan

Registered User.
Local time
Today, 11:13
Joined
Nov 9, 2007
Messages
285
I've been trying to adapt the 'Super Easy Word Function" to my database. I'm slowing finding out what to do. The problem I'm having is on my Vista machine the word app, when launched from Access immediatly minimizes to the taskbar. I've added a reference to MS Word library and then added WordApp.visible = True. But then I get a Runtime Error 91. I'm new to VB and can seem to figure out what is wrong. Mostly because I don't understand yet the explainations. Here is my code.

<code>
Private Sub cmdMerge_Click()
Dim WordApp As Word.Application

' merge the doc
If IsNull(Me.lstFiles) = False Then

Call RidesMergeWord(strDirPath & Me.lstFiles & ".doc", strDirPath, strOutDocName)
DoCmd.Close
WordApp.Visible = True
Else

MsgBox "You need to select a Word document", vbExclamation, "Word Merge"

End If
End Sub

</code>

Please help if you can. I'm sure most of the answers are already posted but I don't know what it means. the word document that I'm opening is called Test.doc.
 
You need to create an instance of the Word application. I don't see where you do that. Either...
Code:
Dim wordApp as New Word.Application
or
Code:
Dim wordApp as Word.Application
set wordApp = CreateObject("Word.Application")
'or
set wordApp = New Word.Application
But you don't appear to actually use Word for anything. You just make it visible.
 
Thank you. That was the problem. It worked.
 
Use this code to be sure it's maximized:
Code:
...
    wordapp.Documents.Parent.Visible = True
    wordapp.Application.WindowState = 1 ' or wdWindowStateMaximize
    wordapp.ActiveWindow.WindowState = 1 ' or wdWindowStateMaximize
    AppActivate "Microsoft Word"
...
 

Users who are viewing this thread

Back
Top Bottom