krnsmartazz
Technical User
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
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, ""
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