A
APH
Hi,
Apologies if this appears twice - not sure if I hit the send button properly
first tyime
Ok, I have a Word document which uses predefined query to supply data for
Mail-merge. The trigger for this is a button with Access, and I use the
code below to launch the Word document .
However if there are no records in the Access query, I need to trap error
code 5631 (I believe) and then drop out of the function. Should I do this
as a separate function before I use the code below, or can it be done within
the code below?
many thanks
Alex
' Opens a word doc in mail merge mode 04/12/03
Dim WordApp As Object
Dim WordDoc As Object
Dim strDocName As String
clsPBar.ShowProgress
clsPBar.TextMsg = "Launching Microsoft Word...please wait..."
On Error GoTo CreateWordApp
Set WordApp = GetObject(, "Word.Application")
On Error GoTo 0
Set WordDoc = WordApp.Documents.Open(strWordDoc)
WordApp.Visible = True
AppActivate "Microsoft Word"
WordApp.WindowState = 0 'wdWindowStateRestore
clsPBar.HideProgress
Exit Function
CreateWordApp:
Set WordApp = CreateObject("Word.Application")
Resume Next
Apologies if this appears twice - not sure if I hit the send button properly
first tyime
Ok, I have a Word document which uses predefined query to supply data for
Mail-merge. The trigger for this is a button with Access, and I use the
code below to launch the Word document .
However if there are no records in the Access query, I need to trap error
code 5631 (I believe) and then drop out of the function. Should I do this
as a separate function before I use the code below, or can it be done within
the code below?
many thanks
Alex
' Opens a word doc in mail merge mode 04/12/03
Dim WordApp As Object
Dim WordDoc As Object
Dim strDocName As String
clsPBar.ShowProgress
clsPBar.TextMsg = "Launching Microsoft Word...please wait..."
On Error GoTo CreateWordApp
Set WordApp = GetObject(, "Word.Application")
On Error GoTo 0
Set WordDoc = WordApp.Documents.Open(strWordDoc)
WordApp.Visible = True
AppActivate "Microsoft Word"
WordApp.WindowState = 0 'wdWindowStateRestore
clsPBar.HideProgress
Exit Function
CreateWordApp:
Set WordApp = CreateObject("Word.Application")
Resume Next