Solved

have a program that is running as a service do something

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
A macro to Count the number of rows across all worksheets 3 149
Getting warning: You are about to delete 1 row(s) 9 53
Hide vba in gp 7 114
Set WorkSheet  not Working 9 51
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…

756 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