Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SendKeys or SendMessage??

Posted on 2001-06-15
6
Medium Priority
?
845 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 1200 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses

715 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