Re: syntactical help by Workgroups
Workgroups
Wed Apr 06 11:47:28 CDT 2005
Yep I think you're right, I'm confusing my textboxes; the 'fm' prefix on
those enumerated values, 'fmTextAlignCenter' and 'fmBorderStyleNone',
probably should have clued me in (I'd been staring at it too long
yesterday). I think I've been trying to fit a "Shape peg" in a "Form
Control hole", so to speak.
Thanks for your help, I'll try my luck with the TextFrame object.
"John" <JohnSickOfSpam@AOL.net> wrote in message
news:OZLwzwoOFHA.3660@TK2MSFTNGP10.phx.gbl...
>I think a shape object has a TextFrame object, so I guess you need to
>reference the shape to add and size and then the TextFrame object to deal
>with the text itself. Maybe something like:
>
> Dim shp As Shape
>
> shp = ActiveDocument.Shapes.AddTextBox........
>
> With shp.TextFrame etc...........
>
> Actually, also looking at your .TextAlign property, I think this is a form
> control textbox property not a normal document textbox (which is a shape
> object). So it looks like you're mixing up your object model. If this is
> the case, just go with the above code.
>
> Anyway I hope this helps.
>
> John
>
> "Workgroups" <noreply@domainless.com> wrote in message
> news:74KdnX2Pw5Lk0s7fRVn-iA@speakeasy.net...
>> I'm trying to use the following method to insert a textbox into a
>> document and format it as I go, but I'm up against some sort of vba
>> compiler/syntactical problem I don't understand yet:
>>
>> With ActiveDocument.Shapes.AddTextBox([orientation, position size etc])
>> ...[various textbox class members here, e.g....]
>> .TextAlign = fmTextAlignCenter
>> .BorderStyle = fmBorderStyleNone
>> [etc]
>> End Width
>>
>> But Option Explicit doesn't like that, presumeably becuase 'AddTextBox'
>> is returning a Shape, not a Textbox.
>>
>> My first instict is to want to do something like...
>>
>> With Ctype(ActiveDocument.Shapes.AddTextBox(...), TextBox)
>> ...[compiler-friendly textbox member references]
>> End With
>>
>> But that's vb.net, not vba. How do I get vba to let me play with what
>> .AddTextBox is returning as if it were a textbox while keeping Option
>> Explicit happy? I don't want to cheat and turn it off. Is there a
>> Ctype-like keyword, a different add-a-textbox method I'm not aware of?
>>
>
>