Results 1 to 2 of 2

Thread: FORMATTING in Writing to a File

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Exclamation

    How can output the word “Status” in blue
    and the word “Complete” in red?



    Open “c:\windows\desktop\Report.doc” For Output As #1
    Print #1, " Status:"
    Print #1, " Complete"
    Close #1


    Thanks.
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    You have to use OLE/ActiveX Automation, a sample is as follows:

    Add a Reference to Microsoft Word 8.0(9.0 if Office 2K) Object Library
    Code:
    Dim w As Word.Application
    
    Set w = CreateObject("Word.Application")
    
    w.Documents.Open ("C:\MyFile.doc")
    
    w.ActiveDocument.Paragraphs.First.Alignment = wdAlignParagraphCenter
    
    With w.ActiveDocument.Words(1) 'set first word
        .Font.Size = 18
        .Font.Color = wdColorBlue
        .Text = "Status: "
    End With
    With w.ActiveDocument.Words(3) 'note skip, ":" is counted as a word
        .Font.Size = 18
        .Font.Color = wdColorRed
        .Text = "Complete"
    End With
    w.ActiveDocument.Save
    w.Visible = True
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width