Go to Post [E]specially when Murphy is around (or at a robotics competition), reality tends to win over physics. - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 26-05-2004, 21:52
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: VB6 Question

First, add a reference to the "Microsoft Word 10.0 Object Library" from the Project->References menu.

This subgroutine will create a new word document and write a block of text to it:
Code:
Sub WriteWordDoc(content As String, _
                 filename As String, _
                 Optional font As String = "Verdana", _
                 Optional fontsize As Integer = 10)
                
    Dim app As Word.Application
    Dim doc As Word.Document
    
    'get an instance of the MS Word application
    Set app = CreateObject("Word.Application")
    
    'create a new document
    Set doc = app.Documents.Add
    
    'initialize the document and write the content
    With doc.content
        .font.Name = font
        .font.Size = fontsize
        .Text = content
    End With
    
    'save the document and close Word
    doc.SaveAs filename
    doc.Close
    app.Quit
    Set doc = Nothing
    Set app = Nothing
End Sub
The app.Quit line is important, otherwise it will keep Word open in the background. If you add the line "app.Visible = true" and remove "app.Quit" then you will see Word open with your new document.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question of the Week [05-02-04]: The Very Merry Month of May EddieMcD Rumor Mill 10 05-05-2004 14:02
MIM's question of the day on programming. Gene F Programming 3 24-02-2004 16:32
A question about control system options computhief263 Control System 7 04-02-2004 14:46
Chief Delphi Site Question Mike Bonham General Forum 1 16-02-2002 22:18


All times are GMT -5. The time now is 15:09.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi