|
-
Apr 10th, 2006, 02:11 PM
#1
Thread Starter
Lively Member
Replacement Text not being replaced.
I am using a form in vb that has a print command button. This pulls up a word doc with text from my form's textboxes. It works fine except in this 'if then' instance. I don't understand why it doens't work. When I place a breakpoint in the code and walk through it, I can see with the text tool tip box that my variable has the right text in, but it will not appear on the word document. It is just blank. Can anybody help?
Code:
strlotarea = Text1(12).Text
Set objWdApp = New Word.Application
Set objWdDoc = objWdApp.Documents.Open(FileName:="\\Taft\gis\test.doc")
Set objwdRange = objWdDoc.Content
With objwdRange.Find
.Replacement.ClearFormatting
.Text = "lotarea"
.Replacement.Text = strlotarea ‘works fine
.Execute Replace:=wdReplaceAll
If Text1(6).Text = "R6" Then
strlotarea = "6,000"
objwdRange.Find.Text = "lotarea"
objwdRange.Find.Replacement.Text = strlotarea ‘left blank on doc.
objwdRange.Find.Execute Replace:=wdReplaceAll
End If
-
Apr 11th, 2006, 07:47 AM
#2
Frenzied Member
Re: Replacement Text not being replaced.
Only a guess but do you need some kind of document refresh after doing that ?
-
Apr 11th, 2006, 01:48 PM
#3
Thread Starter
Lively Member
Re: Replacement Text not being replaced.
There isn't a refresh event/method for the objwdRange. How else can you write it so that it would refresh?
-
Apr 12th, 2006, 01:48 PM
#4
Re: Replacement Text not being replaced.
Hi,
 Originally Posted by kpearson
Code:
With objwdRange.Find
.Replacement.ClearFormatting
.Text = "lotarea"
.Replacement.Text = strlotarea ‘works fine
.Execute Replace:=wdReplaceAll
Here you replaced all the text "lotarea". Now there will be no text "lotarea" in the document.
 Originally Posted by kpearson
Code:
If Text1(6).Text = "R6" Then
strlotarea = "6,000"
objwdRange.Find.Text = "lotarea"
objwdRange.Find.Replacement.Text = strlotarea ‘left blank on doc.
objwdRange.Find.Execute Replace:=wdReplaceAll
End If
How you will find & replace the same text here again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|