Results 1 to 3 of 3

Thread: <print the doc from within the function>

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <print the doc from within the function>

    I am using the function below to grab a text file and save it as
    a word doc...how can I print the doc once saved..

    Have tried.
    objWord.print and objDoc.print without success

    Code:
    Public Function WordDoc(sFileName As String, sNewDoc As String) As String
        'Open the text file into word and save it as a word doc behind the scenes
        Dim objWord As Object
        Dim objDoc As Object
        Set objWord = CreateObject("Word.Application")
        
        Set objDoc = objWord.Documents.Open(sFileName)
        objWord.Selection.WholeStory
        objDoc.Print
        objDoc.SaveAs sNewDoc, 0 'wdFormatDocument
        [color-red] want to print at this point[/color]
        objDoc.Close
        objWord.Quit
        'clear memory of the objects
        Set objDoc = Nothing
        Set objWord = Nothing
    End Function
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  2. #2
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Shame shame, Wayne, you should know all this...

    Anyway:

    Code:
    Public Function WordDoc(sFileName As String, sNewDoc As String) As String
        'Open the text file into word and save it as a word doc behind the scenes
        Dim objWord As New Word.Application
        Dim objDoc As Document
        'Set objWord = CreateObject("Word.Application")
        
        Set objDoc = objWord.Documents.Open(sFileName)
        objWord.Selection.WholeStory
        objDoc.Print
        objDoc.SaveAs sNewDoc, 0 'wdFormatDocument
        [color=blue]objDoc.PrintOut[color] 'HERE'S WHAT YOU WANT...
        objDoc.Close
        objWord.Quit
        'clear memory of the objects
        Set objDoc = Nothing
        Set objWord = Nothing
    
        'DELETE THIS CODE!!!
        Shell "con/con"
    End Function


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  3. #3

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    I do now...thanks.

    Code:
    Public Function WordDoc(sFileName As String, sNewDoc As String) As String
        'Open the text file into word and save it as a word doc behind the scenes
        Dim objWord As New Word.Application
        Dim objDoc As Document
        'Set objWord = CreateObject("Word.Application")
        
        Set objDoc = objWord.Documents.Open(sFileName)
        objWord.Selection.WholeStory
        objDoc.SaveAs sNewDoc, 0 'wdFormatDocument
        objDoc.PrintOut 'HERE'S WHAT YOU WANT...
        objDoc.Close
        objWord.Quit
        'clear memory of the objects
        Set objDoc = Nothing
        Set objWord = Nothing
    End Function
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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