![]() |
|
#1
|
|||
|
|||
![]()
Hello everyone. I hope I word this issue so you can understand what I am trying to accomplish and assist if you can. I created a document that has merge fields and a userform to complete the merged document. I use AutoOpen in a macro to show the userform (Myform.show) and vba to add data per the user selection. It works perfect if I am using on a file with only one party listed in the db. Problem is, if there are more than one parties listed in the db for the file I am merging, the document opens for each listed party and because I have AutoOpen, so does the userform. Is there a way I can have the userform open only once, even if there are multiple parties, but the data the user selects when the userform opens applied to all?
Scenario 4 parties in my file. Userform opens and ask, Question - Is this a renewal? Response = Yes. Selection from drop down list - First Renewal, Second Renewal, Third Renwal. If user selects Second Renewal, how can I have Second Renewal applied each of the four times the document opens without having the form open each time and making the same selection 4 times? Here is the vba I am using. Private Sub Cmdone_Click() If Cbparty = "Yes" Then With ActiveDocument .Bookmarks("Renew1").Range _ .InsertBefore (Cbrenew) .Bookmarks("Renew2").Range _ .InsertBefore (Cbrenew) .Bookmarks("Renew3").Range _ .InsertBefore (Cbrenew) End With End If Me.Hide End Sub Private Sub UserForm_Initialize() Cbparty.AddItem "Yes" Cbparty.AddItem "No" Cbparty.Value = "Select One" Cbrenew.AddItem "Renewal " Cbrenew.AddItem "Second Renewal " Cbrenew.AddItem "Third Renewal " Cbrenew.Value = "Select One" End Sub Private Sub Cbparty_Change() If Cbparty = "Yes" Then Cbrenew.Top = 40 Lbnew.Top = 43 Cmdone.Top = 75 Me.Height = 125 Me.Width = 243 ElseIf Cbparty = "No" Then Cbrenew.Top = 150 Cbrenew.Value = "Select One" Lbnew.Top = 153 Cmdone.Top = 48 Me.Height = 108 Me.Width = 243 End If End Sub |
#2
|
||||
|
||||
![]()
Your use of the term 'merge' may be confusing. I suspect this is not a mail merge?
Your process accesses just one document Code:
With ActiveDocument .Bookmarks("Renew1").Range _ .InsertBefore (Cbrenew) .Bookmarks("Renew2").Range _ .InsertBefore (Cbrenew) .Bookmarks("Renew3").Range _ .InsertBefore (Cbrenew) End With Depending on what you are doing with these documents, you could instead use the one document and use a loop to apply the data four times saving with a different name between each. However in order to do that you would have to write to the bookmark and not next to it. A simple way to do that would be to add and call the FillBM function which is listed on my web site at http://www.gmayor.com/word_vba_examples.htm.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Thank you for responding.
I don't know, maybe this issue would have to work as "loop"? and I am dumb founded with loops. If there are four party defendants, the same document reopens (is repeated) four times, one for each party defendant listed. The answer to the initial question should apply to each document. In my case, the answer user selects applies only in first document and not the other three. Does this make sense? |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
snot369 | Word | 1 | 01-13-2017 11:04 AM |
![]() |
jpaul | Word | 1 | 03-09-2015 01:23 PM |
Word no longer allows multiple documents to be open | Steve's Computer | Word | 1 | 03-22-2014 01:55 PM |
![]() |
MrSnrub | Word | 4 | 06-19-2013 07:32 AM |
![]() |
Oliver Beirne | Word VBA | 2 | 04-24-2012 04:49 AM |