Link to home
Start Free TrialLog in
Avatar of vmccune
vmccuneFlag for United States of America

asked on

Copy Access Report to Clipboard using VBA

Hello,

I want to send a report to the clipboard automatically using VBA.  I have seen how to do one field but I want the entire report as it looks in Print Preview.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Anders Ebro (Microsoft MVP)
Anders Ebro (Microsoft MVP)
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vmccune

ASKER

How would I add the PDF I created to the clipboard?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vmccune

ASKER

Yes I have seen that but there MUST be a more simple approach to this.
A clip must have some kind of format or type or be a file. I'm not sure which of these you would expect to copy from a report, not to say where to paste it.
Pages are displayed one or two at a time, so not even a screenshot will do. Thus, your options are to either export or print the report to Word or PDF.
Once in the clipboard, where will you put it next?  If we were aware of that, maybe we could offer a simpler solution.
Avatar of vmccune

ASKER

The file is a PRF.  Once in the clipboard I want to past to an outlook email or maybe a word document.  My goal is to take a closed pdf and paste it as the open image in the clipboard.  If there would be a better way to do this with just an Access report I can go that way as well.
Then you can use this command:

DoCmd.SendObject acSendReport, "YourReportName", acFormatPDF, "receiver@example.com", , , "Test Print", "Body ...", False

Open in new window

Avatar of vmccune

ASKER

Yes, that would be fine if I was going to email for sure but it may or may not require that.  I really just need to get it to the clipboard so I can paste it wherever I want from that point.
You could set the last parameter to True. Then the mail will not be send automatically, just opened, and you could save the attachment wherever you want.
Not fancy but extremely simple ...
Avatar of vmccune

ASKER

Yes. You are right.  sadly the goal of this effort for the user is not to have to select or hit "Copy" and then "Paste" if it is not an email.  Also many times it will be to respond to an email they have received.   Simply put, I need a command button on a form that will send the Access Report to the clipboard as an image with no additional steps.

Thanks again!
Then we are back at Ander's very first comment ...
Version information would be helpful as well.
For example, if you use the suggestion and create and save the .pdf file to the computer, on 2016 Office apps, the file would be added to the jump list on Outlook. So, when a user replies to an email or starts a new email, the newly created file would be displayed when inserting a file.

What about a message box that would ask what you want to do with the new file?  Then the code could make the next move.
Avatar of vmccune

ASKER

I have 2013.  So message Box or Command Button, If I want the code to take the freshly created PDF file and programmatically paste it to the clipboard, How would I do that?
Anders provided the code in his second post.