Solved

have a program that is running as a service do something

Posted on 2003-11-24
4
224 Views
Last Modified: 2010-05-18
i had a request do use acrobat reader to print a .pdf file with vb6
i found that it could be done whit 'shelling' the acrobat reader and sending keystrokes to it
something along the lines of:
dim a as long
a=shell("theacrobatreader with a file",vbminimizednofocus)
sleep 1000
appactivate a
doevents
sendkeys ("^p")
doevents
appactivate ("Print")
doevents
sendkeys("{ENTER}")
but now i am asked to do it with acrobat reader totally invisible
i have found that it is invisible if shelled with vbHide instead of vbminimizednofocus
but now the acrobat reader runs as a service
so anybody any ideas how to make it print when running as a service ?

 
0
Comment
Question by:foxerke
[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
  • 2
4 Comments
 
LVL 2

Expert Comment

by:MaxPol
ID: 9818198
Hi,

when you shell acrobat, use the following command line prameters:

acrord32.exe /p /h [you pdf file].

That should do what you need.

No more need to use SendKeys.

Hope this help,

Max
0
 

Author Comment

by:foxerke
ID: 9820903
no does not work
the acrobat reader is visible in the taskbar
but i already found the following solution that works:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10

Private Sub Command1_Click()
    ShellExecute Me.hwnd, "print", "c:\test.pdf", vbNullString, vbNullString, 0
End Sub

Private Sub Form_Load()
    'ShellExecute Me.hwnd, "open", "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe", vbNullString, vbNullString, 0
     Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe", vbHide
    'ShellExecute Me.hwnd, "open", "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe", "/h", vbNullString, 0
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Dim a As Long
    a = FindWindow(vbNullString, "Acrobat Reader")
    PostMessage a, WM_CLOSE, 0&, 0&
End Sub

Maxpol
i can do 1 of 2 things:
1) reduce this questions points to 0 and accept it
2)ask support to delete it
please advice
0
 
LVL 2

Accepted Solution

by:
MaxPol earned 500 total points
ID: 9823820
As you prefer,

I think that my suggestion should work.

If you open My Computer and then select:

Tools -> Folder Options

select the tab File Types.

Now look for the exstention PDF.

Now in XP, you should select Advanced, in the Actions text box, select print and then on the right select Edit.

What you see in the normal command that will be launched when you use the right mouse button on a pdf and select print.

So it should work, but check your system, could be that a different version of OS or Acrobat reader have different parameters.

Bye,

Max
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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 Month3 days, 15 hours left to enroll

630 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