mela
09-08-2003, 11:52 AM
Hi EveryBody!
I am trying to automate the input of a printer form, however when I use Sendkey, it doesn't seem to work. My program automatically prints a word document out using a printer. The defaults of the printer are set to "Print to File." Thus, a little form pops up asking me to enter in the output file name. Is there anyway to automate the entry of an output file name? I tried using SendKey, however it is not working for me.
This is what I have:
Public Sub PrintDoc(sDoc As String)
Dim CurrentPrinter As Printer 'This must be declared.
Dim MyDoc As Object 'create a word variable
Set MyDoc = CreateObject("Word.Application")
With MyDoc
For Each CurrentPrinter In Printers
If CurrentPrinter.DeviceName = "apple" Then
Set Printer = CurrentPrinter
Exit For
End If
Next
.Documents.Open sDoc, , True
Printer.Print sDoc
SendKeys "test.prn, {ENTER}"
.ActiveDocument.Close 'Close The Document
.Quit
Set MyDoc = Nothing
End With
End Sub
I think I need to use the .SendKeys method, however I don't know what object to use for it. Thanks in advance for your help!
I am trying to automate the input of a printer form, however when I use Sendkey, it doesn't seem to work. My program automatically prints a word document out using a printer. The defaults of the printer are set to "Print to File." Thus, a little form pops up asking me to enter in the output file name. Is there anyway to automate the entry of an output file name? I tried using SendKey, however it is not working for me.
This is what I have:
Public Sub PrintDoc(sDoc As String)
Dim CurrentPrinter As Printer 'This must be declared.
Dim MyDoc As Object 'create a word variable
Set MyDoc = CreateObject("Word.Application")
With MyDoc
For Each CurrentPrinter In Printers
If CurrentPrinter.DeviceName = "apple" Then
Set Printer = CurrentPrinter
Exit For
End If
Next
.Documents.Open sDoc, , True
Printer.Print sDoc
SendKeys "test.prn, {ENTER}"
.ActiveDocument.Close 'Close The Document
.Quit
Set MyDoc = Nothing
End With
End Sub
I think I need to use the .SendKeys method, however I don't know what object to use for it. Thanks in advance for your help!