Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a textbox with text from a UserForm in word2003

Status
Not open for further replies.

ptempo

Programmer
Jul 4, 2007
4
SE
Hello

I need to insert a textbox with one word in the upper left corner of a document with a sub run from a button click in a UserForm. Any ideas?

// Gustaf
 
ptempo,
Ideas[ol][li]Macro Recorder[/li][li]Help File[/li][li]Object Browser[/li][/ol]
Code:
...
Dim objShape As Object
Set objShape = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 72, 72, 72, 24)
objShape.TextFrame.TextRange = "One Word"
...

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 





Gustaf,

Welcome to Tek Tips.

Please explain in more detail the reason for this requirement.

What is the Textbox for?

How does it relate to the UserForm?

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
I have written a script that runs each time the user presses the 'save as' button in word. When the user does this a doc variable is set to confidential or not confidential. If the document is confidential I want it to say so in the upper corner.

The userform is the place where the user makes the choice.

If it helps, it doesn't matter if the text is written from the UserForm or from the module.

I tried to get it to work with the code CautionMP wrote, it seems to work alright. How do I remove the border and change the font/size?
 
I got this so far

Code:
Dim objShape As Object
    Set objShape = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 72, 72, 72, 24)
    objShape.TextFrame.TextRange = "One Word"
With objShape
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
        .RelativeVerticalPosition = wdRelativeVerticalPositionPage
        .Left = 6
        .Top = 6
        .Line.ForeColor.RGB = RGB(255, 255, 255)
        .ZOrder msoSendBehindText
    End With

It seems to work well, all I need is to figure out how to change the font. Thanks for the help so far.
 
ptempo,
Code:
With objShape
  .TextFrame.TextRange.Font.Name = "Arial"
...

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top