[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MS Word VBA Listbox visible property

Posted on 2005-04-18
12
Medium Priority
?
1,191 Views
Last Modified: 2008-03-17
Hello Friends,

I could not find a forum where I could place this question and this was the closest.

I want to hide a listbox item in MS Word Form using VBA, but I don't see any visible property for the Listbox. Any roundabouts?

Regards,
Srinivas
0
Comment
Question by:srinivas_vemla
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13807470
AFAIK you cant 'hide' individual rows in the standard ListBox, you can only add or remove them.
0
 

Author Comment

by:srinivas_vemla
ID: 13807499
I want to hide the whole listbox. Not a single item in the listbox. Any way to do that in VBA?
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13807515
Yes.  In VBA code use Me.YourLisboxName.Visible = False
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:srinivas_vemla
ID: 13807521
I checked my original question just now. Sorry for phrasing it badly.

I want to hide the listbox "control" (not an item in it) as a whole, but I don't find any property for that. Any suggestions?
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13807528
There should be a .Visible property in every control.  If you don't see it in a Properties dialog, try setting it programmatically and see what happens.
0
 

Author Comment

by:srinivas_vemla
ID: 13807529
The "Visible" property does not seem to be a part of ListBox control in MS Word VBA. I checked that and it gives me an error as no such property.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13807548
I recommend creating a 20-pt 'linking' question in the Word TA, with the URL from this question copy/pasted, so the Word experts can take a crack at providing you a soluition.
0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13808625
Howdy.

jimhorn is right on track, srinivas_vemla.  If you enter code in a Command button or in UserForm.Activate "ListBox1.", it doesn't have "Visible"?  I see it using Word VBA with Office 2000 and Win2k Pro.
0
 
LVL 9

Expert Comment

by:dmang
ID: 13808740
to clarify...

you want to use the listbox in the MS word form (i.e. a document) or on an MS Word Userform?

0
 

Author Comment

by:srinivas_vemla
ID: 13811396
a document dmang, not a userform
0
 
LVL 10

Accepted Solution

by:
edwardiii earned 500 total points
ID: 13811645
You're right, srinivas vemla.  I don't see a visible property in the Project/Microsoft Word Objects/ThisDocument code window.  Here's a possible workaround for you (code goes in the Document/Open method):

Private Sub Document_Open()
    ListBox1.AddItem "howdy"
    ListBox1.Height = 1
    ListBox1.Width = 1
   
    ListBox1.BorderColor = vbWhite
    ListBox1.BackColor = vbWhite
    ListBox1.BorderStyle = fmBorderStyleSingle
End Sub

It makes the Listbox pretty hard to see:) Alternatively, you could disable the Listbox until you want users to have access:

   ListBox1.Enabled = False
0
 

Author Comment

by:srinivas_vemla
ID: 13823597
Thanks edwardiii,

This surely works for me...

Thanks,
Srinivas
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month18 days, 13 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question