Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-08-2009, 12:52 PM
DrewB DrewB is offline VB Code.. COmbo boxes Windows XP VB Code.. COmbo boxes Office 2003
Novice
VB Code.. COmbo boxes
 
Join Date: Feb 2009
Posts: 6
DrewB is on a distinguished road
Default VB Code.. COmbo boxes


I have not done much coding for Word Docs, I have done some in MS Access and what i would like to do I know how to do in Access so I'm sure it can be done in word as well.. here is the deal:
I have about 20 combo boxes in a Word doc and I would like to be able to use a loop to set certain properties or update the text in them, I have them named in this sort of convention ComboBox1, ComboBox2... ComboBox20. I would imagine I should be able to do something like this as I can with Access but it doesn't quite work:

Code:
crt =1
 
do while cnt <= 20
     me("ComboBox" & ctr).value = "I am box #" & ctr
     ctr= ctr + 1
loop
is there a way to do this in MS word??

Last edited by Bird_FAT; 06-08-2009 at 11:31 PM.
Reply With Quote
  #2  
Old 06-08-2009, 11:38 PM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline VB Code.. COmbo boxes VB Code.. COmbo boxes Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Sorry - not found this in Access yet - any chance you could explain what
Code:
crt
Code:
cnt
and
Code:
ctr
do?

As they are obviously not doing the same in Word, it might help you get an answer if you explain what you want to do - not all of us use VBA in Access as much as we do in Word!

One thing you might try is changing the loop from:
Code:
do while cnt <= 20
     me("ComboBox" & ctr).value = "I am box #" & ctr
     ctr= ctr + 1
loop
to:
Code:
While cnt <= 20
     me("ComboBox" & ctr).value = "I am box #" & ctr
     ctr= ctr + 1
Wend
Not being sure about crt, etc. I have no idea if it'll work, but the While used with Wend loop may do the trick.

Last edited by Bird_FAT; 06-09-2009 at 03:37 AM.
Reply With Quote
  #3  
Old 06-09-2009, 05:11 AM
DrewB DrewB is offline VB Code.. COmbo boxes Windows XP VB Code.. COmbo boxes Office 2003
Novice
VB Code.. COmbo boxes
 
Join Date: Feb 2009
Posts: 6
DrewB is on a distinguished road
Default

My appologies, I typed that too fast and called the variable two different things, it should have looked more like this:

Code:
dim ctr 'this will be the counter for the loop
crt =1
 
do while ctr <= 20
     me("ComboBox" & ctr).value = "I am box #" & ctr 
     ctr= ctr + 1
loop
The issue I am having is with the me("ComboBox" & ctr).value, it doesn't work as I expected it to, basically I am trying to find a way to find an equvilant to
me.Combobox1.value where I can use a variable instead of the actual combobox name.

Last edited by Bird_FAT; 06-09-2009 at 11:02 PM.
Reply With Quote
  #4  
Old 06-09-2009, 11:28 PM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline VB Code.. COmbo boxes VB Code.. COmbo boxes Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Have a go at:
Code:
dim ctr As Iterger
dim cbobx As String

Set ctr = 1
Set cbobx = "ComboBox" & ctr

do while ctr <= 20
     me.cbobox.value = "I am box" & ctr 
     ctr= ctr + 1
loop
Don't have time now to try it out, but let me know if it doesn't wor and I'll have a go again, later, to try again.
Reply With Quote
  #5  
Old 06-10-2009, 05:31 AM
DrewB DrewB is offline VB Code.. COmbo boxes Windows XP VB Code.. COmbo boxes Office 2003
Novice
VB Code.. COmbo boxes
 
Join Date: Feb 2009
Posts: 6
DrewB is on a distinguished road
Default

Bird FAT,
I appreciate your reply.. I got the data member not found on the me.cbobox.value = "I am box" & ctr durring the compile. I ended up hard coding everything in for this project but I am still curious if there is something else I could have done..
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Code.. COmbo boxes Hide a combo box DrewB Word 3 06-08-2009 11:29 PM
Problem with Developer Form -- Check Boxes and Text Boxes PCC Word 1 05-16-2009 05:22 AM
PP 2007: Template - Title slide boxes netkos PowerPoint 0 02-19-2009 10:30 AM
VB Code.. COmbo boxes check boxes in outlook 2007 kim Outlook 3 02-17-2009 10:34 AM
Word Text Boxes do not print RogerMantle Word 0 02-16-2009 06:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:15 AM.


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