> Dim oTextBox As MSForms.TextBox
> Set oTextBox = ActiveDocument.InlineShapes(1).OLEFormat.Object
> MsgBox oTextBox.Text
to enable me to reference the various controls in my Word document from VB
5. I have been searching the reference libraries for the object MSForms,
but am unable to find it. Can anyone tell me which library collection it is
in?
Thanks,
Geoff
You can either:
(1) Declare it as a generic object
Dim oTextBox As Object
(2) Set a reference to the "Microsoft Forms 2.0 Object Library" and use:
Dim oTextBox As MSForms.TextBox
If you can't see this library in your list of references, click browse on
the Reference dialog then navigate to and select
"C:\Windows\System32\FM20.dll".
--
Hope this helps.
ibby
Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.
"Geoff & Cynthia Sutton" <Cynn...@Hotmail.com> wrote in message
news:Wg4N8.9989$vo2.2...@news2.telusplanet.net...
Another thing - as I said in my original reply, the ActiveX controls may be
part of the Shapes or InlineShapes collection. The default placement of
these controls varies with the version of Word. You should try Shapes(1)
instead of InlineShapes(1) if VB complains that it can't find the textbox.
--
Hope this helps.
ibby
Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.
"ibby" <ib...@bigpond.net.au> wrote in message
news:O8HO7XKECHA.2444@tkmsftngp05...
I've already done that. I am now able to detect that there are shapes
there, but am finding no way to reference them. Using the oleformat.object
is just getting me type mismatches, and if I declare oTextBox as an object,
I am not able to reference the text property.
Using the shapes collection, I am printing out the names of the controls,
which are declared by word to be Control97 through to Control127 or
something like that. Also, the item(x).type is coming across as a long with
a value of 12 for all controls, labels and textboxes alike.
I don't believe that I am forcing Word to try to do something it's not
equipped for (and it sure bears ProWrite circa 1980!), but they should make
it simpler than this. If I give a control a name inside Word, couldn't Word
at least have the decency you keep that name with that control?
P.S. any suggestions for that curious kink in the back of the neck which
occurs after 14 consecutive hours in front of a laptop? (lol)
Any suggestions you may have would be greatly appreciated. Thanks.
G
----- Original Message -----
From: "ibby" <ib...@bigpond.net.au>
Newsgroups: microsoft.public.word.word97vba
Sent: Monday, June 10, 2002 12:17 PM
Subject: Re: Referencing ActiveX controls
"ibby" <ib...@bigpond.net.au> wrote in message
news:#OpHFsKECHA.2884@tkmsftngp04...
Lets start again :-) BTW, What version of Word are you using ?
(1) Create a new blank document and place one ActiveX TextBox in it. Save it
to "C:\Test\Doc1.doc"
(2) Create a new VB project. Add References to
- "Microsoft Word 9.0 Object Library" (or whichever corresponds to
your version of Word)
(3) Place the following code in a module in the VB project. Run it and let
me know what happens.
---------------------------------------------------
Public Sub Main()
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTextBox As Object
Set oWord = New Word.Application
Set oDoc = oWord.Documents.Open("C:\Test\Doc1.doc")
Set oTextBox = oDoc.Shapes(1).OLEFormat.object
oWord.Visible = True
oTextBox.Text = "Hello"
Set oDoc = Nothing
Set oWord = Nothing
End Sub
---------------------------------------------------
G
"ibby" <ib...@bigpond.net.au> wrote in message
news:eCJtNbPECHA.2456@tkmsftngp02...
Well, anyhow, thank you so very, very much ibby. I owe you one. Or
several. Scream if you want or need some code written.
G.
"ibby" <ib...@bigpond.net.au> wrote in message
news:eCJtNbPECHA.2456@tkmsftngp02...