Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with Code

Status
Not open for further replies.

krnsmartazz

Technical User
Dec 13, 2001
134
US
Someone in this forum recently sent me a database that gets a list of word documents and then opens it, but when i converted it it doesn't work. The problem i get is with this code
Private Sub Command100_Click()
On Error GoTo Err_Command100_Click
Dim oApp As Object
AppActivate "Microsoft Word" ' causes an error if no instance of Microsoft
' Word is actually running.

If Err Then ' Word Was not already running
Set oApp = CreateObject("Word.Application")
Else
Set oApp = GetObject(, "Word.Application")
End If

oApp.Visible = True

'If no file is selected open Microsoft Word with a blank page.
If Nz(txtFilename, "") = "" Then
oApp.Documents.Add
Else
oApp.Documents.Open Filename:=txtPath & txtFilename
End If

oApp.Activate
oApp.WindowState = wdWindowStateMaximize

Exit_cmdWordOpen_Click:
Exit Sub

Err_cmdWordOpen_Click:
MsgBox Err.Description
Resume Exit_cmdWordOpen_Click


Exit_Command100_Click:
Exit Sub

Err_Command100_Click:
MsgBox Err.Description
Resume Exit_Command100_Click

End Sub

*****it compile error varible not defined
 
Hi!

Make sure you have a reference set to MS Word object library, which I assume you do or you would get more errors than that one. My object library says that the constant wdWindowStateMaximize is equal to 1 so you can try replacing the constant with 1.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top