Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Linking with MS Word!

honest_dudehonest_dude Posts: 93Member
I want to print my MS Word Document from my VB program, is there anyway I can link to this file so that I can print straight from the VB program I wrote. I have already created this MS Word file and I want to open this file straight from the VB program. I can open the MS Word program but not the .DOC file I created.

I would be grateful I anyway can help me on this.

Zela

Comments

  • dokken2dokken2 Posts: 532Member
    : I want to print my MS Word Document from my VB program, is there anyway I can link to this file so that I can print straight from the VB program I wrote. I have already created this MS Word file and I want to open this file straight from the VB program. I can open the MS Word program but not the .DOC file I created.
    :
    : I would be grateful I anyway can help me on this.
    :
    : Zela
    :
    :

    Easy with automation, assuming Word is installed on the pc you want to print from-

    [code]
    'PROJECT, REFERENCES..., must set a ref. to-
    'microsoft word 10.0 object library
    Dim WordApp As Word.Application

    Const MyDoc = "C:word.doc" 'sample word document


    Private Sub Command1_Click()
    'init word object
    Set WordApp = New Word.Application
    'show word
    WordApp.Application.Visible = True
    'open word file
    WordApp.Documents.Open MyDoc
    'printpreview
    'WordApp.PrintPreview = True
    'print to printer
    WordApp.PrintOut
    End Sub

    Private Sub Command2_Click()
    'save document
    'WordApp.Documents.Item(MyDoc).Save
    'close document
    'WordApp.Documents.Item(MyDoc).Close False
    'quit word
    WordApp.Quit
    'release resouces
    Set WordApp = Nothing
    End Sub
    [/code]

Sign In or Register to comment.