Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-26-2015, 11:28 AM
Formd Formd is offline Help with Spin button and Do Loop combination Windows 7 32bit Help with Spin button and Do Loop combination Office 2007
Advanced Beginner
Help with Spin button and Do Loop combination
 
Join Date: Feb 2015
Location: TX
Posts: 49
Formd is on a distinguished road
Default Help with Spin button and Do Loop combination

Hello everyone, I am not a pro, so I am coming to the gurus because I desperately need your help using a combination of spin button and Do loop. I am using Do Loop because I do not have a set number.

I created a spin button to allow users to enter the number of specific paragraphs to add to the document. The spin button works fine, problem is getting the info from the document based on the number selected from the spin button. Example,

Question - How many HOA paragraphs do you need?
Answer - User selects 4 with the spin button.

The merge must now insert the paragraph from another document called HOASSOCiation.doc four times. Here is what I tried but did not work.

Private Sub UserForm_Initialize()
With Spnhoa
.Min = 1
.Max = 20
.Value = 1
' Initialize TextBox
Tbhoa.Text = .Value
End With
End Sub


Then, I need the following to happen

Private Sub HOA ()
Dim number As Long
Dim min As Long
Dim max As Long
min = 1
max = 20
Do
number = Tbcondog
Loop Until number: >= min And number <= max
Selection.GoTo What:=wdGoToBookmark, Name:="HOASSOCIATION"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
ChangeFileOpenDirectory "C:\HOA\MERGES\"


Selection.InsertFile FileName:= _
"C:\HOA\MERGES\Association.doc" _
, Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.WholeStory
End Sub

Further
The paragraph reads:
MERGEFIELD Defendant_1 has access to the property........

Each time the paragraph is inserted, the mergefield Defendant_1 also changes.
If user selects 4, then
the first paragraph will merge with Mergefield Defendant_1,
the second paragraph will merge with mergefield Defendant_2,
the third paragraph will merge with mergefield Defendant_3 and
the fourth paragraph will merge with mergefield Defendant_4.
How do I make all this happen? I tried {SEQ Defendant_\*NUMERIC\*MERGEFORMAT} but that did not work.

Help
Reply With Quote
  #2  
Old 10-26-2015, 03:42 PM
macropod's Avatar
macropod macropod is offline Help with Spin button and Do Loop combination Windows 7 64bit Help with Spin button and Do Loop combination Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Perhaps you could explain what you're trying to achieve. It looks like it might be a mailmerge with a variable number of records, for which there are already plenty of solutions, but it's not clear from your post whether that's actually what you're trying to achieve.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-27-2015, 09:24 AM
Formd Formd is offline Help with Spin button and Do Loop combination Windows 7 32bit Help with Spin button and Do Loop combination Office 2007
Advanced Beginner
Help with Spin button and Do Loop combination
 
Join Date: Feb 2015
Location: TX
Posts: 49
Formd is on a distinguished road
Default

Ok, I attached a file and hope this helps.
Attached Files
File Type: doc Association.doc (75.0 KB, 12 views)
Reply With Quote
  #4  
Old 10-27-2015, 02:18 PM
macropod's Avatar
macropod macropod is offline Help with Spin button and Do Loop combination Windows 7 64bit Help with Spin button and Do Loop combination Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Yes, I understand what you're doing, but that doesn't tell me what you're trying to achieve. For example, what are the mergefields for? Are they just being used as placeholders or are you actually proposing to do a mailmerge?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-28-2015, 10:20 AM
Formd Formd is offline Help with Spin button and Do Loop combination Windows 7 32bit Help with Spin button and Do Loop combination Office 2007
Advanced Beginner
Help with Spin button and Do Loop combination
 
Join Date: Feb 2015
Location: TX
Posts: 49
Formd is on a distinguished road
Default

I do not know all the technical terms, I am just learning so I will attempt to respond and hope I do not complicate this further.

Yes I am proposing to do a mailmerge once the user has entered data. I run a macro that opens the userform shown in my previous post. Once the user enters the numbers and hit ok, then the doc merges and pulls the mergefield info from the database AND repeats this per the number(s) entered by the user. I hope this makes sense. If not, what do you suggest? I am on edge because my deadline is fast approaching. Sorry, I am not sure what you mean by placeholders.
Reply With Quote
  #6  
Old 10-28-2015, 02:26 PM
macropod's Avatar
macropod macropod is offline Help with Spin button and Do Loop combination Windows 7 64bit Help with Spin button and Do Loop combination Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

So where do the data come from and how are they structured?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 10-30-2015, 08:55 AM
Formd Formd is offline Help with Spin button and Do Loop combination Windows 7 32bit Help with Spin button and Do Loop combination Office 2007
Advanced Beginner
Help with Spin button and Do Loop combination
 
Join Date: Feb 2015
Location: TX
Posts: 49
Formd is on a distinguished road
Default

Thank you for responding and for you help. I believe you are referring to my statement of "when user enter data..." when you ask about the data? I was referring to the number user inserts at the spin box in the userform. Everything from the proprietary database works fine, I have no problem with that. My only problem and main concern is repeating information/paragraphs in the doc per the number selected. That, I can't get to work. I can get it to work if I use If.. Then... Else but that's a lot to write. If 20 is selected, I don't want to use If... Then... Else 10 times. There has to be an easier way using either the Loop or For next and I am trying to do one of them.
Reply With Quote
  #8  
Old 10-30-2015, 01:18 PM
macropod's Avatar
macropod macropod is offline Help with Spin button and Do Loop combination Windows 7 64bit Help with Spin button and Do Loop combination Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The reason I asked about the data source is that you probably don't need your userform to insert anything; all that's needed is a knowledge of the data structure. After that, it's simply a matter of inserting the appropriate field coding into the document. Once.

It appears you're working with a database that has multiple Defendant fields per record and the max # of Defendant fields is 20. In that case, you could use a document like the attached. The field coding in it provides for all 20 Defendant fields, but only those that have data will actually generate any output. Simply attach it as a mailmerge main document to your database, then Finish the merge and send the output to a new document.
Attached Files
File Type: doc AssociationX.doc (43.0 KB, 12 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 11-02-2015, 07:41 AM
Formd Formd is offline Help with Spin button and Do Loop combination Windows 7 32bit Help with Spin button and Do Loop combination Office 2007
Advanced Beginner
Help with Spin button and Do Loop combination
 
Join Date: Feb 2015
Location: TX
Posts: 49
Formd is on a distinguished road
Default

Thank you for your respond. The attachment will work perfectly if, the inserted paragraph applies to every defendant but it does not apply to all defendents. There has to be a question that asks How many additional paragraphs are needed. Users check the files, to see how many of the defendants in the database needs the paragraphs and selects the number. Based on that number, the amount of paragraphs are inserted. It may only apply to the first three defendants, or maybe the first and third only.
Reply With Quote
  #10  
Old 11-02-2015, 12:57 PM
macropod's Avatar
macropod macropod is offline Help with Spin button and Do Loop combination Windows 7 64bit Help with Spin button and Do Loop combination Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Formd View Post
The attachment will work perfectly if, the inserted paragraph applies to every defendant but it does not apply to all defendents.
Is the need for defendant-specific content identifiable from anything in the database, or can only the user determine that from information stored outside the database?
Quote:
Originally Posted by Formd View Post
It may only apply to the first three defendants, or maybe the first and third only.
Your userform provides no means of inputting that a particular paragraph is required for the first and third defendants only - your form design means anything output for the third defendant would necessarily be output for the first and second defendants also.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 11-12-2015, 09:59 AM
Formd Formd is offline Help with Spin button and Do Loop combination Windows 7 32bit Help with Spin button and Do Loop combination Office 2007
Advanced Beginner
Help with Spin button and Do Loop combination
 
Join Date: Feb 2015
Location: TX
Posts: 49
Formd is on a distinguished road
Default

Because I ran out of time, I used a Combo box with the If, Else Then option. I know there is an easier way, there has to be an easier way but I had to get the doc live. It is lengthy but it gets the job done.
Reply With Quote
  #12  
Old 11-12-2015, 02:33 PM
macropod's Avatar
macropod macropod is offline Help with Spin button and Do Loop combination Windows 7 64bit Help with Spin button and Do Loop combination Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Until you're prepared to answer the question I asked in my previous post, no progress is likely...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Spin button and Do Loop combination Multiple spin animations one after the other maximus123 PowerPoint 1 08-04-2015 05:33 AM
How to copy format of a column using spin button Tyberian1988 Excel Programming 2 03-10-2014 10:09 PM
Help with Spin button and Do Loop combination How to remove Spin button hannu Excel 3 11-14-2013 01:42 AM
Help with Spin button and Do Loop combination tcp-t F3 key combination used in template revans611 Word 1 11-29-2010 11:57 AM
Help with Combination function sanasath Excel 0 12-13-2005 07:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:57 PM.


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