|
-
Mar 4th, 2006, 05:29 AM
#1
Thread Starter
Addicted Member
[resolved] changing a controls propertry - WORD
Hi all,
I have such a problem:
How can I change a controls properties, while referring to the control's name
using a variable??? I have 50 labels named: label1, label2, label3,...,label50. And I would like programmatically change properties of all this labels using loop???
Controls are embedded in document NOT in the form.
I am using Word 2003.
Please help.
Regards,
sweet_dreams
Last edited by sweet_dreams; Mar 4th, 2006 at 04:11 PM.
-
Mar 4th, 2006, 01:14 PM
#2
Re: changing a controls propertry - WORD
This will work for the ActiveX controls.
VB Code:
ThisDocument.TextBox1.Text = "Test"
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 4th, 2006, 01:21 PM
#3
Thread Starter
Addicted Member
Re: changing a controls propertry - WORD
Thx RobDog888
But what should I do to be able to change for examlple 100 such a controls. I would like to use loop to change it's properties at the same time. So how can refer to controls property for eg.
VB Code:
for i=1 to 100
text&i.text="hello" & I
next i
I know that above code looks ridiculous but I would like to do sth like that.
Please help,
sweet_dreams
-
Mar 4th, 2006, 02:07 PM
#4
Re: changing a controls propertry - WORD
]For Each ctl in ThisDocument.InlinShapes
VB Code:
Dim ctl As InlineShape
For Each ctl In ThisDocument.InlineShapes
ctl.OLEFormat.Object.Text = "Test"
Next
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 4th, 2006, 02:09 PM
#5
Re: changing a controls propertry - WORD
VB Code:
Dim i as integer
For i = 1 to Thisdocument.inlineshapes.count
ThisDocument.InlineShapes(i).OLEFormat.Object.Text = "Test " & i
Next
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 4th, 2006, 02:46 PM
#6
Thread Starter
Addicted Member
Re: changing a controls propertry - WORD
Thx once again RobDog888, it works fine.
But do you know is it possible to change properties of only particular control for eg. Label ??? Because I have not only labels but also other controls.
-
Mar 4th, 2006, 02:53 PM
#7
Re: changing a controls propertry - WORD
Yes, you would have to "filter" out to just the type of control you want to edit or by its control name.
VB Code:
ThisDocument.InlineShapes(i).Type =wdInlineShapeOLEControlObject
ThisDocument.InlineShapes(i).OLEFormat.Object.Name
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 4th, 2006, 04:11 PM
#8
Thread Starter
Addicted Member
Re: changing a controls propertry - WORD
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
|