Solved

SendKeys or SendMessage??

Posted on 2001-06-15
6
830 Views
Last Modified: 2008-03-17
I have a simple program which sends text to the user's default printer. The default printer is set to an Acrobat PDF writer. The problem is that when the data is sent to the printer, the printer prompts for an file name to save the file as. The default file name is fine. The only problem I am having is that I am unable to SendKeys or SendMessage to Acrobat's save dialog box to simply accept the default name by passing the ENTER key (or ALT-S would work too).

Please help as soon as possible.

Thank you,

-Keith
0
Comment
Question by:KeithAtWork
6 Comments
 
LVL 3

Expert Comment

by:jrspano
ID: 6196631
are there any settings you can send with your call to the printer?  like pdfprinter.print "filenamehere" ?  I am not familiar with the pdf writer, but i would bet that there are values you can pass to it to save to a certain place and not have it ask you where
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 300 total points
ID: 6196770
this should do it:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_RETURN = &HD

Private Sub Command1_Click()

    Dim hWnd As Long
    Dim lRes As Long
   
    hWnd = FindWindowEx(0, 0, vbNullString, "Print")
    MsgBox hWnd
    lRes = SendMessage(hWnd, WM_KEYDOWN, VK_RETURN, 1)
    lRes = SendMessage(hWnd, WM_KEYUP, VK_RETURN, 1)
   
    MsgBox lRes
   
End Sub

note in the findwindowex call "Print" is the title of the window
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6196775
obviously you don't need to msgbox hWnd and lRes (for your testing, hWnd should be non-zero and lRes should be 0
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6196861
hearing...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6196899
Update to version 4.0.5.0
I did this with OK results:
' Using pdf.ocx

Private Sub Form_Click()
With Pdf1
    .LoadFile "d:\iFtpSvc\ftpserv.pdf"
    .printWithDialog
End With
SendKeys "{ENTER}"
End Sub
0
 

Author Comment

by:KeithAtWork
ID: 6196950
Thanks for your quick response and help!

-Keith
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question