Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Fields in Word have trailing spaces
I am able to automate the pushing of data from an Excel spreadsheet to a Word
document that has form fields using VBA. However, the data that is populated to its respective field pushes the form field 5 spaces to the right of the data. How do I program the data to populate "into" the field without incurring extra spaces. NOTE: This scenario doesn't always happen after running the Excel VBA code. Thanks! -- MD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Fields in Word have trailing spaces
Can you show some of the code you use to do this?
Barb Reinhardt "Lynn" wrote: I am able to automate the pushing of data from an Excel spreadsheet to a Word document that has form fields using VBA. However, the data that is populated to its respective field pushes the form field 5 spaces to the right of the data. How do I program the data to populate "into" the field without incurring extra spaces. NOTE: This scenario doesn't always happen after running the Excel VBA code. Thanks! -- MD |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Fields in Word have trailing spaces
yes, here is a sample where the bookmark (form field) text is set.
(All bookmark values are set in this manner.) objDoc.Bookmarks("txtParagraph1").select objWord.Selection.Text = strParagraph1 Do you need more details? Thanks! -- MD "Barb Reinhardt" wrote: Can you show some of the code you use to do this? Barb Reinhardt "Lynn" wrote: I am able to automate the pushing of data from an Excel spreadsheet to a Word document that has form fields using VBA. However, the data that is populated to its respective field pushes the form field 5 spaces to the right of the data. How do I program the data to populate "into" the field without incurring extra spaces. NOTE: This scenario doesn't always happen after running the Excel VBA code. Thanks! -- MD |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Fields in Word have trailing spaces
Try this for a test
Sub Test() Dim objDoc As Document Dim objWord As Application Dim myFormField As FormField Set objDoc = ThisDocument For Each myFormField In objDoc.FormFields Debug.Print myFormField.Name, myFormField.TextInput.Type, myFormField.TextInput.Type If myFormField.Type = wdFieldFormTextInput And _ myFormField.TextInput.Type = wdRegularText Then myFormField.Result = "Hello" End If Next myFormField End Sub -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "Lynn" wrote: yes, here is a sample where the bookmark (form field) text is set. (All bookmark values are set in this manner.) objDoc.Bookmarks("txtParagraph1").select objWord.Selection.Text = strParagraph1 Do you need more details? Thanks! -- MD "Barb Reinhardt" wrote: Can you show some of the code you use to do this? Barb Reinhardt "Lynn" wrote: I am able to automate the pushing of data from an Excel spreadsheet to a Word document that has form fields using VBA. However, the data that is populated to its respective field pushes the form field 5 spaces to the right of the data. How do I program the data to populate "into" the field without incurring extra spaces. NOTE: This scenario doesn't always happen after running the Excel VBA code. Thanks! -- MD |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Fields in Word have trailing spaces
Thank you, I will test.
-- MD "Barb Reinhardt" wrote: Try this for a test Sub Test() Dim objDoc As Document Dim objWord As Application Dim myFormField As FormField Set objDoc = ThisDocument For Each myFormField In objDoc.FormFields Debug.Print myFormField.Name, myFormField.TextInput.Type, myFormField.TextInput.Type If myFormField.Type = wdFieldFormTextInput And _ myFormField.TextInput.Type = wdRegularText Then myFormField.Result = "Hello" End If Next myFormField End Sub -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "Lynn" wrote: yes, here is a sample where the bookmark (form field) text is set. (All bookmark values are set in this manner.) objDoc.Bookmarks("txtParagraph1").select objWord.Selection.Text = strParagraph1 Do you need more details? Thanks! -- MD "Barb Reinhardt" wrote: Can you show some of the code you use to do this? Barb Reinhardt "Lynn" wrote: I am able to automate the pushing of data from an Excel spreadsheet to a Word document that has form fields using VBA. However, the data that is populated to its respective field pushes the form field 5 spaces to the right of the data. How do I program the data to populate "into" the field without incurring extra spaces. NOTE: This scenario doesn't always happen after running the Excel VBA code. Thanks! -- MD |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Fields in Word have trailing spaces
Thanks again!
This works when running it from Word. There are no trailing spaces. Hmmmm... Do I use the ".Result" instead of ".Text" when running the code from Excel? Is this what makes the difference, perhaps? -- MD "Barb Reinhardt" wrote: Try this for a test Sub Test() Dim objDoc As Document Dim objWord As Application Dim myFormField As FormField Set objDoc = ThisDocument For Each myFormField In objDoc.FormFields Debug.Print myFormField.Name, myFormField.TextInput.Type, myFormField.TextInput.Type If myFormField.Type = wdFieldFormTextInput And _ myFormField.TextInput.Type = wdRegularText Then myFormField.Result = "Hello" End If Next myFormField End Sub -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "Lynn" wrote: yes, here is a sample where the bookmark (form field) text is set. (All bookmark values are set in this manner.) objDoc.Bookmarks("txtParagraph1").select objWord.Selection.Text = strParagraph1 Do you need more details? Thanks! -- MD "Barb Reinhardt" wrote: Can you show some of the code you use to do this? Barb Reinhardt "Lynn" wrote: I am able to automate the pushing of data from an Excel spreadsheet to a Word document that has form fields using VBA. However, the data that is populated to its respective field pushes the form field 5 spaces to the right of the data. How do I program the data to populate "into" the field without incurring extra spaces. NOTE: This scenario doesn't always happen after running the Excel VBA code. Thanks! -- MD |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Fields in Word have trailing spaces
Barb,
It works! Never mind about the last question. I used this type of assignment for each field -- objDoc.FormFields("txtParagraph1").Result = strParagraph1 Thank you so much! It was mind-boggling there for a while. You have been most helpful! Have a great day! -- MD "Barb Reinhardt" wrote: Try this for a test Sub Test() Dim objDoc As Document Dim objWord As Application Dim myFormField As FormField Set objDoc = ThisDocument For Each myFormField In objDoc.FormFields Debug.Print myFormField.Name, myFormField.TextInput.Type, myFormField.TextInput.Type If myFormField.Type = wdFieldFormTextInput And _ myFormField.TextInput.Type = wdRegularText Then myFormField.Result = "Hello" End If Next myFormField End Sub -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "Lynn" wrote: yes, here is a sample where the bookmark (form field) text is set. (All bookmark values are set in this manner.) objDoc.Bookmarks("txtParagraph1").select objWord.Selection.Text = strParagraph1 Do you need more details? Thanks! -- MD "Barb Reinhardt" wrote: Can you show some of the code you use to do this? Barb Reinhardt "Lynn" wrote: I am able to automate the pushing of data from an Excel spreadsheet to a Word document that has form fields using VBA. However, the data that is populated to its respective field pushes the form field 5 spaces to the right of the data. How do I program the data to populate "into" the field without incurring extra spaces. NOTE: This scenario doesn't always happen after running the Excel VBA code. Thanks! -- MD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
trailing spaces | Excel Worksheet Functions | |||
Microsoft Query sometimes adds trailing spaces to fields | Excel Discussion (Misc queries) | |||
REMOVING TRAILING SPACES | Excel Discussion (Misc queries) | |||
remove trailing spaces | Excel Discussion (Misc queries) | |||
Excel pivot fields and trailing spaces | Excel Programming |