Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > How do I use the Tag property?


Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2003, 01:11 PM
AlexanderBlade AlexanderBlade is offline
Freshman
 
Join Date: May 2003
Posts: 44
Default How do I use the Tag property?


Hi, there is no indexing property in VBA for word. I created a lot of textboxes but I need to treat them like an array so that I can loop through them all.

My question is, how can I use the tag property to loop through the controls?

Please Help
Reply With Quote
  #2  
Old 06-26-2003, 01:42 PM
Wamphyri's Avatar
Wamphyri Wamphyri is offline
Variable not defined

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Ottawa, Ontario
Posts: 4,793
Default

You can loop through the controls collection. And decide from there which controls are textboxes and which aren't.
Code:
With UserForm1.Controls For i = 0 To .Count - 1 MsgBox .Item(i).Name Next End With
__________________
-Carl
Reply With Quote
  #3  
Old 06-27-2003, 08:51 AM
AlexanderBlade AlexanderBlade is offline
Freshman
 
Join Date: May 2003
Posts: 44
Default

The thing is I'm not using a userform. I'm using a Word document to I will have to rererence the control through ThisDocument. I don't see a Controls collection in the properties of the ThisDocument.

Reply With Quote
  #4  
Old 06-27-2003, 09:44 AM
Wamphyri's Avatar
Wamphyri Wamphyri is offline
Variable not defined

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Ottawa, Ontario
Posts: 4,793
Default

In a word document textboxes are either InlineShapes or Shapes depending on what you've set them to. The default is InlineShapes.
Code:
With ThisDocument.InlineShapes For i = 1 To .Count MsgBox .Item(i).OLEFormat.ClassType Next End With
__________________
-Carl
Reply With Quote
  #5  
Old 06-27-2003, 05:01 PM
AlexanderBlade AlexanderBlade is offline
Freshman
 
Join Date: May 2003
Posts: 44
Default

Thanks for the help Wamphyri, is there any way that I can read the value of my textboxes. I thought I could use the tag or index to do it but now that I've seen your code, I don't know how to use it.

Is there anyway for me to loop through lots of textboxes this way?


Thanks again
Reply With Quote
  #6  
Old 06-28-2003, 07:47 AM
Wamphyri's Avatar
Wamphyri Wamphyri is offline
Variable not defined

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Ottawa, Ontario
Posts: 4,793
Default

It would be pretty useless if there wasn't a way. Just use the Object property of OLEFormat. Then you can use any property that the textbox has.
Code:
With ThisDocument.InlineShapes 'Loop through InLineShapes For i = 1 To .Count 'Check if InLineShape is a Textbox If .Item(i).OLEFormat.ClassType = "Forms.TextBox.1" Then 'Display text of Textbox MsgBox .Item(i).OLEFormat.Object.Text End If Next End With
__________________
-Carl
Reply With Quote
  #7  
Old 06-29-2003, 12:34 AM
AlexanderBlade AlexanderBlade is offline
Freshman
 
Join Date: May 2003
Posts: 44
Default

Thank you so much for your help. That worked perfectly. You are a genius!!!!!! Now I can finally sleep
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Contact Note Villain Excel 1 06-03-2003 10:05 PM
Open an associated Text Document knoxitis General 19 05-01-2002 11:26 PM
type mismatch in form load knoxitis General 32 04-26-2002 10:52 AM
data type mismatch in criteria expression knoxitis General 16 04-23-2002 09:15 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->