|
-
Feb 23rd, 2006, 03:59 AM
#1
Thread Starter
New Member
Userforms in Word Comboboxes
Hello,
I am pretty new to VBA and all kind of fun stuff, so apologies if this questions is boring. I tried to find some good tutorials on the web, but they seem to be very hard to find for Word 2003 (lots for Excel though).
Anyway, I have created a UserForm in a Word Document, and successful added them to the Bookmarks in my documents. Most of the entries is done via text boxes, however I also use 5 Comboboxes.
1) With the combo boxes I have an issue, I've used the .AddItem statement. And now if I open the form I click on the arrow, nothing is in there. If I type any character in the box, and press the arrow, my list is populated. If I close and re-open, it's there twice. what I want is a fixed list a user cannot edit/change and the contents are there directly.
VB Code:
Private Sub cboTimeZoneSetup_Change()
With cboTimeZoneSetup
.AddItem "Czech-Czech Republic"
.AddItem "Danish-Denmark"
.AddItem "Dutch-Belgium"
End With
End Sub
2) I want to be able to check the input on amount of characters and if the content matches for example a ZIP code.
3) I have an input of the following: Location Concept, Location Number, Type of Machine, Number of Machine. With this information I want to add text in my document with the computernames which need to be used. So for example: amount of machines is 3, a loop should execute 3 times and generate "WS4330MC001", "xxx002" "xxx003". So WS is Concept, 4430 is Location, MC is fixed information, 001 is the number based on the amount (so it could also be 032).
VB Code:
Private Sub cmdSubmit_Click()
Dim strConcept As String
Dim strLongConcept As String
If radioConceptWS = True Then strConcept = "WS" & strLongConcept = "Walibi"
If radioConceptAG = True Then strConcept = "AG" & strLongConcept = "Argue"
If radioConceptPA = True Then strConcept = "PA" & strLongConcept = "Parental"
If radioConceptIN = True Then strConcept = "IN" & strLongConcept = "Invis"
If radioConceptTM = True Then strConcept = "TM" & strLongConcept = "Travo M"
Dim NoPos, PCNames, strRegName
NoPos = PCQnt 'PCQnt is amount of machines
For NoPos = PCQnt To 1 Step -1
strRegName = strRegName & vbvrlf & strConcept & txtLocNumber & NoPos
Next NoPos
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("PMName").Range.Text = txtPMName.Value
' etc
End With
Application.ScreenUpdating = True
Unload Me
End Sub
4) At the end I want to autosave the document with Location Concept, Location Number, thus example WS4330.doc on a fixed path (\\server\share\dir)
Sorry lots of questions however I hope they are easy to resolve. Any help and tips are welcome.
Thanks a lot in advance,
Bart
Edit: added code
Last edited by dago; Feb 23rd, 2006 at 04:05 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|