Ohad1997

New Member
Joined
Aug 13, 2017
Messages
21
for my understanding using sendmessage is a more reliable way to simulate key press then using sendKeys

How can i replace this line of code:

SendKeys "^a"

With a sendMessage alternative?
 
Hello Jaafar,

Good to hear back from you. The code is setup to make the PDF file the window with the focus and then send the Ctrl+, Ctrl+C, which should be processed by the active window. I admit is not perfect and I have a lot of problems with the PDF window. It does not behave as regular Window. I used both SendMessage and PostMessage with no results. I could not find a window that supported IDispatch. That is why I chose the way I did.

The free version of Acrobat Reader is pretty limited as far as automation. I agree it would be nice to use the native PDF API to do this. However, it is only available in the Professional version of Acrobat Reader. My computer runs on 64 bit Windows and uses Office 10. I did not write the code exclusively for 64 bit machines but should have written the code to be compatible with 64 bit since the OP did not say which platform was being used.
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
leith ross your code is amazing, but it sometimes failed to copy and went into an infinite loop, i fixed it by

SetForegroundWindow (hwnd)

just before the call copy and it works perfectly
it also gave me an error saying the selected area isnt the same as the paste size
easily fixed by using the data directly from the clipboard
just one thing left that i cant wrap my head around, how can i terminate the pdf's after the copy end?
tried
sendkeysAPI(VK_F4)

but it doesnt work
any suggestions?
 
Upvote 0
Hello Ohad1997,

It is curious the code works as I posted on my system yet both you and Jaafar experience different issues. It seems significant but I don't know what it means.

I actually had tried the GetForegroundWindow initially when writing the code but the results on my end were not stable using that method either. The only reliable way I could get the paste to happen was activate the PDF window and give it the focus, send the Ctrl+A and Ctrl+C commands, manually minimize the PDF window, and manually paste the data on the worksheet. Every other method I tried always randomly failed at some point.

I will look into the VK_F4 problem and see if there is a problem with my code or if this is another PDF quirk.
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,824
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top