Solved

SendKeys or SendMessage??

Posted on 2001-06-15
6
824 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now