![]() |
Printing a Word document from Excel spreadsheet
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 |
Printing a Word document from Excel spreadsheet
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 |
Printing a Word document from Excel spreadsheet
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 |
Printing a Word document from Excel spreadsheet
In a Visual Basic Editor, click on Tools menu and select references.
References window appears. Scroll down and find 'Microsoft Word 11.0 Object Library'' (depending upon your version it might not be 11.0, something else, hence I put xx.x.) Check the box fot that library and click on OK. Sharad "ringo tan" wrote in message ... 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 |
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 |
Printing a Word document from Excel spreadsheet
Thanks Dave :)
"Dave Peterson" wrote in message ... 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 the quotation out. Thank you. Ringo Tan -- Dave Peterson |
All times are GMT +1. The time now is 09:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com