Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Transfer Data from ListBox to MergeFields

Ive always found the help in this Excel Programming DG to be tremendously
valuable (and from time to time I try to offer valuable help too). Recently,
I posted a Word-based question to the Word Programming group, but only got
one response and I didnt know what to do with the advice I got so Im coming
here for help. I may, or may not, get the answer here. Lets see. Anyway,
I am currently facing a challenge to get data from a ListBox in MS Word,
which originally comes from Excel, into about 32 MergeFields in a Word
template that I created.

Everything works, with the exception of the final transferring of data from
a ListBox into several MergeFields in my Word document. The code below works
for Bookmarks, but not for MergeFields. I dont know how to create code that
takes data from a ListBox and transfers this data into the appropriate
MergeFields. The code for doing this for Bookmarks is displayed below:

Private Sub CommandButton1_Click()
Dim i As Integer, Addressee As String
Addressee = ""
For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Addressee = Addressee & ListBox1.Value & vbCr
Next i
ActiveDocument.Bookmarks("Addressee").Range.Insert After Addressee
UserForm1.Hide
End Sub


Doug gave me this code over the summer. It works great for Bookmarks in a
Word document, but it doesnt do anything for me now that I am using
MergeFields. Some of my MergeFields are as follows:
{MERGEFIELD City \* MERGEFORMAT}
{MERGEFIELD State \* MERGEFORMAT}
{MERGEFIELD Number \* MERGEFORMAT}
€¦etc.

For a full explanation of the issue, and all related details, here is a link
to the post on the Word Programming DG:
http://www.microsoft.com/office/comm...sloc=en-us&p=1

Any help would be greatly appreciated!!

Regards,
Ryan--


--
RyGuy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Transfer Data from ListBox to MergeFields

Ryan,

Mergefields are meant for merging an Excel (or other) database into a file template, creating a
multiple-page document, with one copy of the document per record. If you want to manually (or
through code) do that sort of merging, a simple way with a macro is to use placeholders in your
document. For example, if you document has

Hello ZZZZNameZZZZ,

My friend ZZZZFriendZZZZ told me about a great opportunity in the field of bridge sales...

Then you could do a Find/Replace of ZZZZNameZZZZ with the appropriate value, and so on.

Otherwise, instead of doing a field by field replacement, try recording the actual mail merge...

HTH,
Bernie
MS Excel MVP


"ryguy7272" wrote in message
...
I've always found the help in this Excel Programming DG to be tremendously
valuable (and from time to time I try to offer valuable help too). Recently,
I posted a Word-based question to the Word Programming group, but only got
one response and I didn't know what to do with the advice I got so I'm coming
here for help. I may, or may not, get the answer here. Let's see. Anyway,
I am currently facing a challenge to get data from a ListBox in MS Word,
which originally comes from Excel, into about 32 MergeFields in a Word
template that I created.

Everything works, with the exception of the final transferring of data from
a ListBox into several MergeFields in my Word document. The code below works
for Bookmarks, but not for MergeFields. I don't know how to create code that
takes data from a ListBox and transfers this data into the appropriate
MergeFields. The code for doing this for Bookmarks is displayed below:

Private Sub CommandButton1_Click()
Dim i As Integer, Addressee As String
Addressee = ""
For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Addressee = Addressee & ListBox1.Value & vbCr
Next i
ActiveDocument.Bookmarks("Addressee").Range.Insert After Addressee
UserForm1.Hide
End Sub


Doug gave me this code over the summer. It works great for Bookmarks in a
Word document, but it doesn't do anything for me now that I am using
MergeFields. Some of my MergeFields are as follows:
{MERGEFIELD City \* MERGEFORMAT}
{MERGEFIELD State \* MERGEFORMAT}
{MERGEFIELD Number \* MERGEFORMAT}
.etc.

For a full explanation of the issue, and all related details, here is a link
to the post on the Word Programming DG:
http://www.microsoft.com/office/comm...sloc=en-us&p=1

Any help would be greatly appreciated!!

Regards,
Ryan--


--
RyGuy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Transfer Data from ListBox to MergeFields

This item has been resolved; it is no longer outstanding:
http://www.microsoft.com/office/comm...sloc=en-us&p=1

Thanks!!
Ryan--


--
RyGuy


"Bernie Deitrick" wrote:

Ryan,

Mergefields are meant for merging an Excel (or other) database into a file template, creating a
multiple-page document, with one copy of the document per record. If you want to manually (or
through code) do that sort of merging, a simple way with a macro is to use placeholders in your
document. For example, if you document has

Hello ZZZZNameZZZZ,

My friend ZZZZFriendZZZZ told me about a great opportunity in the field of bridge sales...

Then you could do a Find/Replace of ZZZZNameZZZZ with the appropriate value, and so on.

Otherwise, instead of doing a field by field replacement, try recording the actual mail merge...

HTH,
Bernie
MS Excel MVP


"ryguy7272" wrote in message
...
I've always found the help in this Excel Programming DG to be tremendously
valuable (and from time to time I try to offer valuable help too). Recently,
I posted a Word-based question to the Word Programming group, but only got
one response and I didn't know what to do with the advice I got so I'm coming
here for help. I may, or may not, get the answer here. Let's see. Anyway,
I am currently facing a challenge to get data from a ListBox in MS Word,
which originally comes from Excel, into about 32 MergeFields in a Word
template that I created.

Everything works, with the exception of the final transferring of data from
a ListBox into several MergeFields in my Word document. The code below works
for Bookmarks, but not for MergeFields. I don't know how to create code that
takes data from a ListBox and transfers this data into the appropriate
MergeFields. The code for doing this for Bookmarks is displayed below:

Private Sub CommandButton1_Click()
Dim i As Integer, Addressee As String
Addressee = ""
For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Addressee = Addressee & ListBox1.Value & vbCr
Next i
ActiveDocument.Bookmarks("Addressee").Range.Insert After Addressee
UserForm1.Hide
End Sub


Doug gave me this code over the summer. It works great for Bookmarks in a
Word document, but it doesn't do anything for me now that I am using
MergeFields. Some of my MergeFields are as follows:
{MERGEFIELD City \* MERGEFORMAT}
{MERGEFIELD State \* MERGEFORMAT}
{MERGEFIELD Number \* MERGEFORMAT}
.etc.

For a full explanation of the issue, and all related details, here is a link
to the post on the Word Programming DG:
http://www.microsoft.com/office/comm...sloc=en-us&p=1

Any help would be greatly appreciated!!

Regards,
Ryan--


--
RyGuy




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
How to transfer a ListBox to a function Stefan Mueller[_2_] Excel Programming 2 July 17th 07 08:15 AM
Transfer ListBox items to a range AD108 Excel Programming 2 September 10th 06 01:49 PM
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
transfer data in listbox Glen Mettler[_2_] Excel Programming 1 September 24th 04 10:44 AM
Transfer multiple columns items form listbox to range Rolo[_3_] Excel Programming 3 November 15th 03 06:50 PM


All times are GMT +1. The time now is 08:09 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"