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

how do you send text to MSWord?

Status
Not open for further replies.

psykloak1

Programmer
Aug 31, 2001
6
US
hi, im making a program and I depratly need some help. I need to know how to send text to MSWord. if ANY one knows how please respond ASAP!
tanx!
 
Didn't have time to whip up a pretty example, so I striped some code from one of my apps. This should get you started. I put this macro into Excel and ran it, and there you have it.

Add the Microsoft Word Object Library to your Project>References.
Code:
Sub test()
    Set wdApp = New Word.Application
    wdApp.Visible = True
    wdApp.WindowState = wdWindowStateMaximize
    wdApp.Documents.Add
    
    With wdApp.Selection
        .Font.Size = 48
        .TypeParagraph
        .TypeParagraph
        .ParagraphFormat.Alignment = wdAlignParagraphCenter
        .TypeText Text:="Appendix"
        .TypeParagraph
        .Font.Size = 12
        .ParagraphFormat.Alignment = wdAlignParagraphLeft
        .InsertBreak Type:=wdSectionBreakNextPage
    End With
    'Finish Up
    wdApp.Selection.HomeKey Unit:=wdStory
'    wdApp.ActiveDocument.SaveAs FileName:=sAppendix
    
    wdApp.Activate
    Set wdApp = Nothing
End Sub
Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top