Chunk
10-06-2015, 09:47 AM
Hi everyone,
I have a userform with an "address" text box. Don't know if it makes a difference but the userform was created through excel.
I want the user to be able to use the return key in the text box to have the address appear as follows (on the userform):
John Wayne
123 Easy St
Pocohontas, NE
87598
I would like to then copy the address to the document in the same format.
I can get the text to copy from the userform to the document, just not with the desired formatting. Any ideas? Here is the code I am currently working with:
Private Sub btn_Continue_Click()
Dim wrdApp As Object
Dim wrdNNDF As Object
Set wrdApp = CreateObject("Word.Application")
Set wrdNNDF = wrdApp.Documents.Open("C:\template.doc")
wrdNNDF.Activate
wrdApp.Selection.Find.ClearFormatting
wrdApp.Selection.Find.Replacement.ClearFormatting
wrdNNDF.doc_RR_tbox_address.Text = TESTMASTER_optbut.tbox_address.Text
wrdNNDF.PrintOut
wrdNNDF.Close SaveChanges:=wdDoNotSaveChanges
wrdApp.Quit
Unload Me
End Sub
I have a userform with an "address" text box. Don't know if it makes a difference but the userform was created through excel.
I want the user to be able to use the return key in the text box to have the address appear as follows (on the userform):
John Wayne
123 Easy St
Pocohontas, NE
87598
I would like to then copy the address to the document in the same format.
I can get the text to copy from the userform to the document, just not with the desired formatting. Any ideas? Here is the code I am currently working with:
Private Sub btn_Continue_Click()
Dim wrdApp As Object
Dim wrdNNDF As Object
Set wrdApp = CreateObject("Word.Application")
Set wrdNNDF = wrdApp.Documents.Open("C:\template.doc")
wrdNNDF.Activate
wrdApp.Selection.Find.ClearFormatting
wrdApp.Selection.Find.Replacement.ClearFormatting
wrdNNDF.doc_RR_tbox_address.Text = TESTMASTER_optbut.tbox_address.Text
wrdNNDF.PrintOut
wrdNNDF.Close SaveChanges:=wdDoNotSaveChanges
wrdApp.Quit
Unload Me
End Sub