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

x
?
Solved

have a program that is running as a service do something

Posted on 2003-11-24
4
Medium Priority
?
227 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 2000 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

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.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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

704 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