Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2017, 09:34 AM
Formd Formd is offline Open Userform once and apply the same selection to multiple documents Windows 7 32bit Open Userform once and apply the same selection to multiple documents Office 2007
Advanced Beginner
Open Userform once and apply the same selection to multiple documents
 
Join Date: Feb 2015
Location: TX
Posts: 46
Formd is on a distinguished road
Default Open Userform once and apply the same selection to multiple documents

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
Reply With Quote
  #2  
Old 11-20-2017, 10:09 PM
gmayor's Avatar
gmayor gmayor is offline Open Userform once and apply the same selection to multiple documents Windows 10 Open Userform once and apply the same selection to multiple documents Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
If you want it to access more documents, you need to open each document in turn (or create new documents from a template) and apply the data to each.

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
Reply With Quote
  #3  
Old 12-12-2017, 10:11 AM
Formd Formd is offline Open Userform once and apply the same selection to multiple documents Windows 7 32bit Open Userform once and apply the same selection to multiple documents Office 2007
Advanced Beginner
Open Userform once and apply the same selection to multiple documents
 
Join Date: Feb 2015
Location: TX
Posts: 46
Formd is on a distinguished road
Default

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?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Userform once and apply the same selection to multiple documents Apply Heading Style When Combining Documents snot369 Word 1 01-13-2017 11:04 AM
Open Userform once and apply the same selection to multiple documents Saving multiple open Word documents 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
Open Userform once and apply the same selection to multiple documents How to apply a list style to multiple Word documents? MrSnrub Word 4 06-19-2013 07:32 AM
Open Userform once and apply the same selection to multiple documents Apply template to multiple documents Oliver Beirne Word VBA 2 04-24-2012 04:49 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft