Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

Controls Collection + VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hemant - 04 Mar 2007 08:01 GMT
Hi,

    I have placed some controls (from View -> Toolbars -> Control Toolbox) on
the word form. I 'm restricted to use controls from this toolbox only. What i
have been asked is to have a button on a word form and when that button is
clicked, i must display using a msgbox, the name of the control, its caption
and some other properties of the control.

    I have tried this but it is not helping me.

    Dim fld As Field
    dim fldCount as Integer
    dim intIndex as Integer

    for intIndex = 1 to ThisDocument.Fields.Count
        Set fld = ThisDocument.Fields(intIndex)

        If fld.Type = TextboxType Then
            ' show text box name and text
        elseif fld.Type = CheckboxType then
            ' show checkbox name and checked state (T / F)
        elseif ....(more controls)
               End If
    Next intIndex
Perry - 04 Mar 2007 09:30 GMT
Just got my mind off a solution posted by macropod, couple of threads up ...
*few*
The impressive ones, they resonate ...

Back to yr quest
Either you've coded incorrectly, or y're using the wrong fields.

If y're trying to loop through FormFields (View|Toolbars|Forms) then
yr code should do it.
If y're trying to loop through controls from the
toolbox(View|Toolbars|Control Toolbox) , the code is not
correct. These are ActiveX controls and do you really want to use them?
Anyhow, you can do somehting like:

   Dim ils As InlineShape
   For Each ils In ActiveDocument.InlineShapes
       Select Case ils.OLEFormat.ClassType
           Case "Forms.CheckBox.1"

           Case "Forms.TextBox.1"
           Case "Forms.Combobox.1"
           case ...etc
       End Select
   Next

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE

> Hi,
>
[quoted text clipped - 22 lines]
>                End If
> Next intIndex
Helmut Weber - 04 Mar 2007 11:08 GMT
Hi everybody,

>    Dim ils As InlineShape
>    For Each ils In ActiveDocument.InlineShapes
[quoted text clipped - 5 lines]
>        End Select
>    Next

yes, but it could be a shape as well.

Would be nice, if there was a kind of a graphical object,
representing both shapes and inlineshapes.

Maybe there is, but at least I haven't found out yet.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Perry - 04 Mar 2007 13:16 GMT
> Would be nice, if there was a kind of a graphical object,
> representing both shapes and inlineshapes.

Ah ah, uh uh, yep, I'm with you.
That would be very, very convenient, although when it comes to ActiveX
controls,
I don't like to use them in a Word document :-(

Excel "sheet" objects counter: ? Me.OLEObjects.Count
beautifully, by the way ...

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE

> Hi everybody,
>
[quoted text clipped - 14 lines]
>
> Maybe there is, but at least I haven't found out yet.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.