Solved

SendKeys or SendMessage??

Posted on 2001-06-15
6
835 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses
Course of the Month7 days, 6 hours left to enroll

622 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