Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I wish to create a spreadsheet which will have a series of
buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Danny,
I don't know how to put up the word dialog to set the number of copies, but the code below will do the same thing: set your file path and name where obvious. The code requires that you set a reference to Word in your project - set your reference to the oldest version of Word that your users will be using, since references only automatically update from older to newer versions but not newer to older. HTH, Bernie Sub PrintWordDocument() Dim oWord As Word.Application Set oWord = CreateObject("word.application") oWord.Documents.Open "C:\folder\Word file name.doc" oWord.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) oWord.Application.Quit (False) End Sub "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tried the method below and could not get it to work. I
have very limited VBA knowledge and i could not work out where i tell it that i want it to work on Word 97 and above? Any help would be appreciated. Danny. -----Original Message----- Danny, I don't know how to put up the word dialog to set the number of copies, but the code below will do the same thing: set your file path and name where obvious. The code requires that you set a reference to Word in your project - set your reference to the oldest version of Word that your users will be using, since references only automatically update from older to newer versions but not newer to older. HTH, Bernie Sub PrintWordDocument() Dim oWord As Word.Application Set oWord = CreateObject("word.application") oWord.Documents.Open "C:\folder\Word file name.doc" oWord.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) oWord.Application.Quit (False) End Sub "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Danny
1) Go to the VBA editor, Alt -F11 2) ToolsReferences in the Menu bar 3) Place a Checkmark before Microsoft Word? Object Library ? is the Excel version number -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... Tried the method below and could not get it to work. I have very limited VBA knowledge and i could not work out where i tell it that i want it to work on Word 97 and above? Any help would be appreciated. Danny. -----Original Message----- Danny, I don't know how to put up the word dialog to set the number of copies, but the code below will do the same thing: set your file path and name where obvious. The code requires that you set a reference to Word in your project - set your reference to the oldest version of Word that your users will be using, since references only automatically update from older to newer versions but not newer to older. HTH, Bernie Sub PrintWordDocument() Dim oWord As Word.Application Set oWord = CreateObject("word.application") oWord.Documents.Open "C:\folder\Word file name.doc" oWord.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) oWord.Application.Quit (False) End Sub "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The code runs now and the printer comes up in the taskbar
as if it is printing, but then nothing gets through to the printer? Here is my code - Sub Rectangle2_Click() Dim oWord As Word.Application Set oWord = CreateObject("word.application") oWord.Documents.Open "C:\Test.doc" oWord.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) oWord.Application.Quit (False) End Sub I can follow most of the code but don't understand how the input box is telling the printer how many copies it wants. This code seems too simple for this complex task? Could someone explain how this is working and why my document never actually gets printed? Thanks Danny. -----Original Message----- Hi Danny 1) Go to the VBA editor, Alt -F11 2) ToolsReferences in the Menu bar 3) Place a Checkmark before Microsoft Word? Object Library ? is the Excel version number -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... Tried the method below and could not get it to work. I have very limited VBA knowledge and i could not work out where i tell it that i want it to work on Word 97 and above? Any help would be appreciated. Danny. -----Original Message----- Danny, I don't know how to put up the word dialog to set the number of copies, but the code below will do the same thing: set your file path and name where obvious. The code requires that you set a reference to Word in your project - set your reference to the oldest version of Word that your users will be using, since references only automatically update from older to newer versions but not newer to older. HTH, Bernie Sub PrintWordDocument() Dim oWord As Word.Application Set oWord = CreateObject("word.application") oWord.Documents.Open "C:\folder\Word file name.doc" oWord.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) oWord.Application.Quit (False) End Sub "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. . . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Is working for me Try this Sub test() Dim WD As Object Set WD = CreateObject("Word.Application") WD.Documents.Open ("C:\ron.doc") WD.ActiveDocument.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) WD.Quit Set WD = Nothing End Sub Copies is a part of the PrintOut code See the VBA help for PrintOut -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... The code runs now and the printer comes up in the taskbar as if it is printing, but then nothing gets through to the printer? Here is my code - Sub Rectangle2_Click() Dim oWord As Word.Application Set oWord = CreateObject("word.application") oWord.Documents.Open "C:\Test.doc" oWord.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) oWord.Application.Quit (False) End Sub I can follow most of the code but don't understand how the input box is telling the printer how many copies it wants. This code seems too simple for this complex task? Could someone explain how this is working and why my document never actually gets printed? Thanks Danny. -----Original Message----- Hi Danny 1) Go to the VBA editor, Alt -F11 2) ToolsReferences in the Menu bar 3) Place a Checkmark before Microsoft Word? Object Library ? is the Excel version number -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... Tried the method below and could not get it to work. I have very limited VBA knowledge and i could not work out where i tell it that i want it to work on Word 97 and above? Any help would be appreciated. Danny. -----Original Message----- Danny, I don't know how to put up the word dialog to set the number of copies, but the code below will do the same thing: set your file path and name where obvious. The code requires that you set a reference to Word in your project - set your reference to the oldest version of Word that your users will be using, since references only automatically update from older to newer versions but not newer to older. HTH, Bernie Sub PrintWordDocument() Dim oWord As Word.Application Set oWord = CreateObject("word.application") oWord.Documents.Open "C:\folder\Word file name.doc" oWord.PrintOut Copies:=Application.InputBox _ ("Number of Copies?", , , , , , , 1) oWord.Application.Quit (False) End Sub "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. . . |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this
Set WD = CreateObject("Word.Application") WD.Documents.Open ("C:\ron.doc") WD.ActiveDocument.PrintOut WD.Quit Set WD = Nothing -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim WD As Object
I forgot this line -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for this. The code worked and printed out the
document. Is there not a way i can get the print dialogue box up before printing this way the user can enter how many copies they want? Alternatively a simple window asking for a user input for the number of copies would be even better. How do i put a delay on closing Word cause i currently get the quitting word will cancel all print jobs message? Thanks a lot, Danny. -----Original Message----- Dim WD As Object I forgot this line -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. . |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the example from Bernie for the copies
How do i put a delay on closing Word cause i currently get the quitting word will cancel all print jobs message? Check out DisplayAlerts in the VBA help for th -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... Thanks for this. The code worked and printed out the document. Is there not a way i can get the print dialogue box up before printing this way the user can enter how many copies they want? Alternatively a simple window asking for a user input for the number of copies would be even better. How do i put a delay on closing Word cause i currently get the quitting word will cancel all print jobs message? Thanks a lot, Danny. -----Original Message----- Dim WD As Object I forgot this line -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. . |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Danny,
I took a Word document with some boilerplate text and inserted a bookmark that I named "Bookmark1" I saved it as a Word template rather than a Word document. The macro below will open Word if it isn't already open, load the template, insert whatever I have in cell A1 on sheet 1 immediately after the bookmark, bring up the print dialog, execute the print after I set the number of copies and it will close word without warnings or saving the new document. See if you can modify it to fit your needs. Sub PrintFromTemplate() Dim bStarted As Boolean Dim oApp As Word.Application Dim str1 As String str1 = Sheets("Sheet1").Cells(1, 1).Value On Error Resume Next Set oApp = GetObject(, "Word.Application") 'Get the running instance of Word, if there is no instance 'create a new one: If Err < 0 Then bStarted = True Set oApp = CreateObject("Word.Application") End If oApp.Activate oApp.Visible = True oApp.Documents.Add Template:="Test.dot" oApp.ActiveDocument.Bookmarks("Bookmark1").Range.I nsertAfter str1 oApp.Dialogs(wdDialogFilePrint).Show oApp.ActiveDocument.PrintOut Background:=False, Copies:=0 oApp.ActiveDocument.Close wdDoNotSaveChanges 'Quit only when Word was not running when we started this code If bStarted Then oApp.Quit End If Set oApp = Nothing End Sub Steve "Danny" wrote in message ... Thanks for this. The code worked and printed out the document. Is there not a way i can get the print dialogue box up before printing this way the user can enter how many copies they want? Alternatively a simple window asking for a user input for the number of copies would be even better. How do i put a delay on closing Word cause i currently get the quitting word will cancel all print jobs message? Thanks a lot, Danny. -----Original Message----- Dim WD As Object I forgot this line -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Danny" wrote in message ... I wish to create a spreadsheet which will have a series of buttons on it linking to a collection of Word documents. What would the code be to print a Word document from an Excel macro. Ideally i would like the Print dialogue window to appear so that i can specify the number of copies before printing. Any help would be greatly appreciated. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Printing Word Documents from Excel | Excel Discussion (Misc queries) | |||
Printing from email without Word/Excel | Excel Worksheet Functions | |||
Embedding Word Docs into Excel Worksheets and Then Printing The Word Docs | Excel Worksheet Functions | |||
Printing MS Word Doc From MS Excel | Excel Discussion (Misc queries) | |||
Printing Word doc from Excel | Excel Programming |