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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter text into Open Word File 1

Status
Not open for further replies.

chris921

Technical User
Mar 9, 2004
82
GB
Hi,

I have the following bit of code, that enters text into a blank word file when opened.

Code:
Set word_server = CreateObject("Word.Application")
    word_server.Caption = "My Document"
    word_server.documents.Add , , wdNewBlankDocument, True
    word_server.activedocument.PageSetup.Orientation = wdOrientLandscape
    word_server.activedocument.PageSetup.TopMargin = 72 '72 points = 1 inch.
    word_server.activedocument.PageSetup.BottomMargin = 72
    word_server.activedocument.PageSetup.LeftMargin = 36
    word_server.activedocument.PageSetup.RightMargin = 36
    word_server.activedocument.content.InsertParagraph
    word_server.activedocument.content.InsertParagraph
    word_server.activedocument.content.Paste 'If you have an image in clipboard
    word_server.activedocument.content.InsertParagraphAfter
    word_server.activedocument.content.insertafter " My Text Here "
    word_server.Visible = True

I also have a form opening up on top of the word document - the form contains a label (whose caption changes depending on the selection in the combo box), a combo box and a button.

I want to know if:
a) Its possible to enter the caption of the label into the open word file when pressing the button
and b) How far off I am (a pointer or two in the right direction would be helpful too!?)?

When I've tried putting the following line into the button's "clicked" procedure, it says Object Missing...
Code:
    word_server.activedocument.content.insertafter myTextLabel.Caption

I'm not asking for someone to write it out for me - unless they REALLY want to - as I'm learning as I do it, just not sure what to be looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top