Chunk
10-01-2015, 10:31 AM
I have a userform that the user will fill out a text box:
tbox_Title
When the command button is pressed, on the userform, a Word document opens that contains the following Active X textbox:
doc_RR_tbox_Title
I cannot get the text, from the userform, to populate the Word doc textbox.
Any ideas?
Here is the code I am trying to use:
Set wrdApp = CreateObject("Word.Application")
Set wrdNNDF = wrdApp.Documents.Open("C:\Review.doc")
wrdNNDF.Activate
'wrdApp.Visible = True
wrdApp.Selection.Find.ClearFormatting
wrdApp.Selection.Find.Replacement.ClearFormatting
FindWhat = Array("AAA", "CCC", "DDD")
ReplaceWith = Array(tbox_Location.Text, tbox_Date.Text, tbox_Comment.Text)
For i = 0 To 2
With wrdApp.Selection.Find
.Text = FindWhat(i)
.Replacement.Text = ReplaceWith(i)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wrdApp.Selection.Find.Execute Replace:=wdReplaceAll
Next i
''''''this is where it fails
doc_RR_tbox_TGI.Text = TESTMASTER.tbox_Title.Text
wrdNNDF.PrintOut
wrdNNDF.Close SaveChanges:=wdDoNotSaveChanges
wrdApp.Quit
Unload Me
End Sub
Thanks in advance.
Chunk
tbox_Title
When the command button is pressed, on the userform, a Word document opens that contains the following Active X textbox:
doc_RR_tbox_Title
I cannot get the text, from the userform, to populate the Word doc textbox.
Any ideas?
Here is the code I am trying to use:
Set wrdApp = CreateObject("Word.Application")
Set wrdNNDF = wrdApp.Documents.Open("C:\Review.doc")
wrdNNDF.Activate
'wrdApp.Visible = True
wrdApp.Selection.Find.ClearFormatting
wrdApp.Selection.Find.Replacement.ClearFormatting
FindWhat = Array("AAA", "CCC", "DDD")
ReplaceWith = Array(tbox_Location.Text, tbox_Date.Text, tbox_Comment.Text)
For i = 0 To 2
With wrdApp.Selection.Find
.Text = FindWhat(i)
.Replacement.Text = ReplaceWith(i)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wrdApp.Selection.Find.Execute Replace:=wdReplaceAll
Next i
''''''this is where it fails
doc_RR_tbox_TGI.Text = TESTMASTER.tbox_Title.Text
wrdNNDF.PrintOut
wrdNNDF.Close SaveChanges:=wdDoNotSaveChanges
wrdApp.Quit
Unload Me
End Sub
Thanks in advance.
Chunk