Return (Control) to Access....

themanof83

Registered User.
Local time
Today, 07:07
Joined
May 1, 2008
Messages
73
Afternoon All!

I have a function (activated through a Command Button) that opens up a PDF, copies the contents then tries to paste this into a field on the form. I am having trouble getting the function to return correctly to the open Access Application and hence the correct form field.
Ive tried the AppActivate statement (using "Microsoft Access" and "Microsoft Office Access" as the arguements) but it throws up a reference error.
I've also tried Access.Application.Visible = True, again with no luck.

Any ideas on how to return to Access???

Code:
'Get PDF path, open PDF and  copy text
strCurPDF = GetFolderSpec & Me.QTGTest & ".pdf"
Call OpenPDFDocument(strCurPDF, True)
Wait_timer (3)

'Return to access
!!!!!!!!!!!! 

'Set Focus to Field
Forms!QTG!PDFPass.SetFocus
    
    Wait_timer (1)
    
        SendKeys "^(v)"     'Ctrl-V (Paste)
       
    Wait_timer (1)
 
reveal for the unsuspecting readers what the code of OpenPDFDocument is
 
OpenPDFDocument is purely a function that:
  • Gets the executable path for the file type association (.pdf)
  • Checks the version of adobe reader/acrobat based on the information in this path
  • Uses the Shell statement to open the file name passed to the function with the appropriate program
  • Dependant on the version, sends a bunch of sendkey statements (in this case it is purely Ctrl-A (Select All), Ctrl-C (Copy) and Alt-Space-C (Close))
I can tell this works perfectly as the selected text remains in the clipboard...
 
Last edited:
google shellandwait, which will render control back to access when done. shell does its own thing, and it can be tricky to check whether it has finished with whatever it was doing

i am assuming that the problem is here. But maybe I am wrong.

What are you copying from your pdf? There is some free code out there that lets you read a pdf from command line: http://en.wikipedia.org/wiki/Pdftotext nd output it as text file - I use that to extract order data that come as email attachments, without visibly opening any new application. If your problem is that focus remains in your shell-started external app, then this would perhaps solve it.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom