PDA

View Full Version : Word Macro to get pdf data appended



janith
04-21-2012, 11:24 PM
Can some one help me with this problem. I want a set of pages containing images when copied from Adobe Reader individually to automatically append on the word file i am using , I want to use this function on Word occasionally so should also be able to stop the macro when not in use ... any assistance thank u in advance

macropod
04-22-2012, 06:54 PM
Hi janith,

Word cannot automate PDF data extraction unless you have Adobe Acrobat Pro installed. The free Reader doesn't come with the necessary tools.

In any event, for something that's only used occasionally, I can't see what better results you're going to get than what you'll achieve via a manual copy/paste process. FWIW, coding a macro to do anything more than always adding the copied content to a specific location (eg the end of the document) in a pre-defined document (hard-coded path & name) or one selected via some form of file-selection dialog for each & every copy/paste can be quite involved.

janith
04-23-2012, 09:51 AM
Surely...

I'm thinking there should be a much easy way to achieve this. By using a function like getclipboarddata() . After all what I just wanted was to copy image from PDF and WORD using VBA should get this data from clipboard and append to my word document and refresh its buffer every time a do a right click copy on the PDF image. Still hopeful.... somebody there can help me with this!!!

Frosty
04-23-2012, 10:35 AM
Janith,

It's hard to tell if you want to change what is in your clipboard, or you want to further modify the results after you paste into your word document.

Can you spell out exactly what you want to happen, step-by-step... i.e.,

1. Open PDF File
2. Open Word file
3. Copy multiple pages from PDF file
4. Paste into Word document
5. Separate out multiple pages in Word document with different captions.

In short, if you describe the process you're currently doing... you can get a solid answer on whether it's possible/impossible/easy/hard.

janith
04-23-2012, 10:47 AM
Hi

sure I will elaborate it..

1)click on a macro button (START) on word to start copy/paste.
2)go to pdf and copy the image on page 1
3)when clicked copy it should show up on word document automatically instead of I pasting it there.
4)when copy page 2 on pdf i.e image again.
5)it should append the already existing image on the word.
6)goes on until I reach the end of pdf image.
7)by end of what ever i copied on pdf should show on getting appended to word document.
8)once done I should be able to click on a macro button on word say(STOP) which will stop performing the above actions.

Hope this helps....

Frosty
04-23-2012, 10:58 AM
Janith,

That sounds like what you want the macro to do, not what you currently do. Is that accurate?

What do you *currently* do? Because what you're describing you want the macro to do is *not* easy, and would require either a) Acrobat Pro (which allows programmatic hooks into the application the Reader does not allow) or b) a complete stand-alone application which would monitor what you do in Word and Acrobat to capture actual Windows/System events.

However, if you describe what you currently do... you will be able to get some available options to facilitate/accelerate that without needing to do either a) or b) above.

Frosty
04-23-2012, 11:04 AM
For example, I could imagine a not terribly difficult macro which could facilitate the following workflow:

1. Word document open
2. PDF file open
3. Select image in PDF file
4. Switch to Word document
5. Click "Paste My PDF Image" macro
6. image is pasted into Word, at the end of the document, with a caption title, additional formatting as an inline shape, or a floating shape, etc etc
7. Switch back to PDF
8. Select new image
9. Switch back to Word
10. Repeat from #5 until done with PDF document.

With a combination of ALT+TAB and a short cut key assigned to your Word macro... you would spend the most time selecting the page in Acrobat and copying it... the rest would be pretty quick.

However, once you start interacting with an external program, it requires some pretty advanced coding, which may or may not be possible/easy.

macropod
04-23-2012, 03:14 PM
Surely...

I'm thinking there should be a much easy way to achieve this. By using a function like getclipboarddata() . After all what I just wanted was to copy image from PDF and WORD using VBA should get this data from clipboard and append to my word document and refresh its buffer every time a do a right click copy on the PDF image. Still hopeful.... somebody there can help me with this!!!
The only way you could do anything like that is by having an API in the parent application (in this case whatever has the PDF open). Acrobat Reader has no API of any kind; that's why you'd need Acrobat Pro. Even then, I'm not sure the Acrobat Pro API has anything that allows you to detect that something has been copied to the clipboard so that it could then automate the pasting of that content into another application.

Saying:

VBA should get this data from clipboard and append to my word document and refresh its buffer every time a do a right click copy on the PDF image
is all very well, but without an API it's about as easy as pushing water up a hill.

Frosty
04-23-2012, 03:20 PM
But Paul... all you need to push water up a hill is a wheelbarrow and a bucket! ;)

Janith: as you can see, this would probably be a very tall order to have a "one-click wonder button" -- but that's not to say that your task couldn't be automated in *some* fashion to allow you to do what you want to do more quickly.

It's just a question of probably managing your own expectations and the limits of what can easily be achieved with the available resources (if you don't have the money to purchase Acrobat Pro, or the money to program your own stand-alone program, you are limited by what is available programatically from *within* an existing program-- which in Acrobat Reader is nothing, and in Microsoft Word is whatever is already in the clipboard when you are *about* to paste into Word).

Hope this all helps

macropod
04-23-2012, 03:30 PM
That's carrying, not pushing...

The water's on the sandy ground and the sun is shining. The bucket's got a hole in it (you've got no straw and your scissors are blunt anyway) and your barrow has only one handle. On top of that you have nothing to collect the water with. Your time starts now ...

fumei
04-23-2012, 04:02 PM
LOL

Frosty
04-23-2012, 04:11 PM
Haha. Well played.

Although the brief time I spent in Australia 25 years ago... while I found things a *bit* different, I thought you all pushed your wheelbarrows too,...just upside down. ;)