Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
trailing spaces peter Excel Worksheet Functions 3 October 18th 07 11:32 PM
Microsoft Query sometimes adds trailing spaces to fields No Name Excel Discussion (Misc queries) 1 June 4th 07 03:17 PM
REMOVING TRAILING SPACES Tris Excel Discussion (Misc queries) 5 August 29th 06 03:36 PM
remove trailing spaces les8 Excel Discussion (Misc queries) 4 January 20th 06 03:55 PM
Excel pivot fields and trailing spaces Fred Excel Programming 1 June 17th 05 09:52 PM


All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"