S
slickdock
I posted this in VBA for beginners, but got no reply. I'll try here...
I have this simple macro in word, and I'd like to execute it from an msAccess
module:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
..Text = "a"
..Replacement.Text = "b"
..Forward = True
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
I know enough to preface the above code with:
Dim wd As Object
Dim wdActiveDoc As Object
Dim wdField As Object
Set wd = CreateObject("Word.Application")
Then I know enough to add the following wd. prefix to these lines:
wd.Selection.Find.ClearFormatting
wd.Selection.Find.Replacement.ClearFormatting
With wd.Selection.Find
But after the END WITH, it's bombing out on this line:
wd.Selection.Find.Execute Replace:=wdReplaceAll
Any help would be greatly appreciated.
I have this simple macro in word, and I'd like to execute it from an msAccess
module:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
..Text = "a"
..Replacement.Text = "b"
..Forward = True
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
I know enough to preface the above code with:
Dim wd As Object
Dim wdActiveDoc As Object
Dim wdField As Object
Set wd = CreateObject("Word.Application")
Then I know enough to add the following wd. prefix to these lines:
wd.Selection.Find.ClearFormatting
wd.Selection.Find.Replacement.ClearFormatting
With wd.Selection.Find
But after the END WITH, it's bombing out on this line:
wd.Selection.Find.Execute Replace:=wdReplaceAll
Any help would be greatly appreciated.