Solved

have a program that is running as a service do something

Posted on 2003-11-24
4
206 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 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

16 Experts available now in Live!

Get 1:1 Help Now