View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Printing a Word document from Excel spreadsheet

Another option that maybe be safer (you won't have to worry about different
versions of word):

Just change this line:
Dim appWD As Word.Application, myPath As String
to
Dim appWD As Object, myPath As String

This is called late binding. Excel will figure out what you want from the
createobject() line.

When you do this: "Dim appWD As Word.Application", it's called early
binding--you're telling excel that you'll handle the details.

Early binding is nice for development (and it's slightly quicker
(unnoticeable???), but with late binding you don't have to worry about
supporting multiple versions of office.

(and it's an easy change!)

ringo tan wrote:

Hi Sharad,

Thank you for your kind help but i dont know how to add the reference
"Microsoft Word xx.x Object Library" in Excel?

Thank you

"Sharad Naik" wrote:

In excel first add reference to "Mocrosoft Word xx.x Object Library"
Then:-

Sub WdocPrinter()
Dim appWD As Word.Application, myPath As String
myPath = "C:\My Documents" 'Set the path for your quotation.doc file
Set appWD = CreateObject("Word.Application")
appWD.Documents.Open Filename:=myPath & "\quotation.doc"
With appWD.ActiveDocument
.PrintOut
.Close
End With
End Sub

Sharad

"ringo tan" wrote in message
...
Hi,

I would like to check whether how to control open, print and close a Word
document say, 'quotation.doc' from Excel.

I need to perform this operation because I have to do my detailed
calculations in Excel in order to derive at a final quotation price,
afterwhich dump this price on a Word template (quotation.doc) and print
the
quotation out.

Thank you.



Ringo Tan





--

Dave Peterson