SendKeys Problem

G

Guest

Hi folks,

My default printer is PDFWriter. I have the following code to export my
report to pdf format. The code is working perfect in Access 97. It gave me
a hard time when I used in Access XP (2002). It output my report to
c:\temp\rpt1.pdf and then it output my report again and have a pop up window
for the file name. Could anyone tell me the way to fix it?

Thanks in advance.

Tim.

Public Sub test()

SendKeys "c:\temp\rpt1.pdf" & "{ENTER}", False
DoCmd.OpenReport "rpt1", acViewNormal

End Sub
 
G

Guest

Tim,

I didn't see your post before putting up mine just a few minutes ago. We're
having a problem with SendKeys in Office 2003 and ours also worked in Office
97.

What exactly is happning? Is it just not working? When I step through my
code I can see that it is generating the "keys" but the timing is off. Is
that also happening to you?
 
A

Alex White MCDBA MCSE

Hi,

I see you are both suffering the same problem, I hate SendKeys, what I can
recommend if either of you are reasonable at vb and have the vb6 compiler to
hand in a project on sourceforge, called PDFCreator, written in vb6 with
source code, works everytime, is a direct PDF printer, you could modify the
code to make it take the file name from a registry key or database record
and print automatically, I know it's a bit of work but SendKeys drives me
round the bend.

http://prdownloads.sourceforge.net/pdfcreator/PDFCreator-Source-0_8_0.zip?use_mirror=heanet

Hey I might just modify myself. (next year when I finish my current
workload)
 
G

Guest

I love it. You discovered that the SendKeys would execute but so slowely that
the open report would open before the SendKeys wourld arive.

The code is supposed to execute in a linear fassion. First one then the
other. Like you I sometimes could dismiss a dialog box by SendKeys before the
dialog box would open. This is very risky and not dependable at all. However,
if the macros stop executing while the dialog box is open it may have been
you only hope to automate such a thing.

Your order is wrong.

Now the other problem is that the SendKeys will execute before the dialog
box is opened.

You need to waste some time.


Public Sub test()
Dim Wwait

DoCmd.OpenReport "rpt1", acViewNormal
'A loop designed to make windows wait untill it draws the dialog box
For Wwait = 1 to 1000000
Next Wwait
' {Home} usually brings the cursor to the front of the fiield. {Shift}{End}
selects the entire field. Just in case there is data or a directory already
present.
SendKeys "{Home 20}+{end}c:\temp\rpt1.pdf{ENTER}", False



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top