View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Danny[_4_] Danny[_4_] is offline
external usenet poster
 
Posts: 17
Default Printing a Word doc from Excel

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.


.



.