T
traderjoes
I created a form and some VBA code behind it in a Word doc file. Under the
ThisDocument (Microsoft Word Objects) for Document_Open() I have the
following code:
Private Sub Document_Open()
form1.Show
End Sub
That kicks off the form but I get a Run-time error '5852': Requested object
is not available. I did a line by line execution run and found that the error
occurs in this line
strPatMasterID =
ThisDocument.MailMerge.DataSource.DataFields("PatentMasterID").Value
The problem is order in which the code is executed. The mailmerge (based on
msquery) is kicked off after the form opens (or in this case because of the
error, when I click "end" to stop the code)... so obiviously it cannot
retrieve the mailmerge.datasource.datafields if the mailmerge doesn't run
first.
So, does anyone how now I can manipulate the run order of the VBA code or
explicitly force the msquery to run first before I retrieve the data? Would
setting a timer work?
thanks in advance for your help
ThisDocument (Microsoft Word Objects) for Document_Open() I have the
following code:
Private Sub Document_Open()
form1.Show
End Sub
That kicks off the form but I get a Run-time error '5852': Requested object
is not available. I did a line by line execution run and found that the error
occurs in this line
strPatMasterID =
ThisDocument.MailMerge.DataSource.DataFields("PatentMasterID").Value
The problem is order in which the code is executed. The mailmerge (based on
msquery) is kicked off after the form opens (or in this case because of the
error, when I click "end" to stop the code)... so obiviously it cannot
retrieve the mailmerge.datasource.datafields if the mailmerge doesn't run
first.
So, does anyone how now I can manipulate the run order of the VBA code or
explicitly force the msquery to run first before I retrieve the data? Would
setting a timer work?
thanks in advance for your help