J
Jon Petitta
In a form that I created in Access I'm pulling data from
tables and running a find and replace in word. I was
developing on one machine and it worked fine. Went to
another machine, and it gave me an invalid procedure
call. I checked the ver's in word and the one that works
is 10.4219.4219, the one that doesn't is 10.5522.4219. I
updated the other machine and now they both don't work.
It does everything else, it opens word, opens the doc, but
stops on the find and gives me an error. If I take out
the find it works fine. The code works as a macro when
running local to word, but when I try to run from access
it gives me the error. Here is the code in Access VBA
Private Sub word_Click()
Dim intLBIndex As Integer
On Error GoTo Err_word_Click
intLBIndex = Me.lbQuote.ListIndex
strSStreet = Me.lbQuote.Column(1, intLBIndex)
strSCity = Me.lbQuote.Column(2, intLBIndex)
strSState = Me.lbQuote.Column(3, intLBIndex)
strSZip = Me.lbQuote.Column(4, intLBIndex)
Set oApp = New word.Application
oApp.Visible = True
oApp.Documents.Open ("d:\project\complete set of
forms\Remediation Agreement Contract v3.1.doc")
With oApp.Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%ClientName"
.Replacement.Text = strClientName
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteSTreet"
.Replacement.Text = strSStreet
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteCity"
.Replacement.Text = strSCity
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteState"
.Replacement.Text = strSState
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteZip"
.Replacement.Text = strSZip
.Execute Replace:=wdReplaceAll
End With
oApp.ActiveWindow.ActivePane.View = wdPrintView
oApp.ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
oApp.ActiveWindow.ActivePane.View.NextHeaderFooter
With oApp.Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%ClientName"
.Replacement.Text = strClientName
.Execute Replace:=wdReplaceAll
End With
oApp.ActiveDocument.SaveAs ("d:\project\complete set
of forms\booya.doc")
oApp.Application.Quit
Exit_word_Click:
Exit Sub
Err_word_Click:
MsgBox Err.Description
Resume Exit_word_Click
End Sub
Any help would be greatly appreciated
Jon
tables and running a find and replace in word. I was
developing on one machine and it worked fine. Went to
another machine, and it gave me an invalid procedure
call. I checked the ver's in word and the one that works
is 10.4219.4219, the one that doesn't is 10.5522.4219. I
updated the other machine and now they both don't work.
It does everything else, it opens word, opens the doc, but
stops on the find and gives me an error. If I take out
the find it works fine. The code works as a macro when
running local to word, but when I try to run from access
it gives me the error. Here is the code in Access VBA
Private Sub word_Click()
Dim intLBIndex As Integer
On Error GoTo Err_word_Click
intLBIndex = Me.lbQuote.ListIndex
strSStreet = Me.lbQuote.Column(1, intLBIndex)
strSCity = Me.lbQuote.Column(2, intLBIndex)
strSState = Me.lbQuote.Column(3, intLBIndex)
strSZip = Me.lbQuote.Column(4, intLBIndex)
Set oApp = New word.Application
oApp.Visible = True
oApp.Documents.Open ("d:\project\complete set of
forms\Remediation Agreement Contract v3.1.doc")
With oApp.Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%ClientName"
.Replacement.Text = strClientName
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteSTreet"
.Replacement.Text = strSStreet
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteCity"
.Replacement.Text = strSCity
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteState"
.Replacement.Text = strSState
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%SiteZip"
.Replacement.Text = strSZip
.Execute Replace:=wdReplaceAll
End With
oApp.ActiveWindow.ActivePane.View = wdPrintView
oApp.ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
oApp.ActiveWindow.ActivePane.View.NextHeaderFooter
With oApp.Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "%ClientName"
.Replacement.Text = strClientName
.Execute Replace:=wdReplaceAll
End With
oApp.ActiveDocument.SaveAs ("d:\project\complete set
of forms\booya.doc")
oApp.Application.Quit
Exit_word_Click:
Exit Sub
Err_word_Click:
MsgBox Err.Description
Resume Exit_word_Click
End Sub
Any help would be greatly appreciated
Jon