Access VBA image copy

2019-07-27 15:15发布

I have a report generated by my access program. Each record in the report has a picture that is stored externally and referenced with a file path. I want to have a way for my users to copy the pictures so they can paste them into an email or document. Since the pictures are stored externally the copy function is not available from the right click context menu. Is there a way I can add in a button and use VBA to get the picture from the file path and place it in the clipboard?

3条回答
Deceive 欺骗
2楼-- · 2019-07-27 15:56

You can try the steps detailed in http://support.microsoft.com/kb/210216 however from the same description of the article:

"Microsoft Access does not have a command that sends information to the Clipboard. To post information to the Clipboard, you need to define a Visual Basic for Applications function that calls several Microsoft Windows API functions. This article shows you how to create a function that copies text to the Clipboard. "

so if this answers yur question deppends on how comfy you are on creating functions and using APIs

查看更多
狗以群分
3楼-- · 2019-07-27 15:59

You could add something like this to the Double-Click event for the image:

Shell "RunDLL32.exe C:\Windows\System32\Shimgvw.dll,ImageView_Fullscreen " _
   & Me.FullPathtoImage

this will open it in the Windows Picture and Fax Viewer from where the user can copy and so on.

查看更多
地球回转人心会变
4楼-- · 2019-07-27 16:01

Well I figured out a decent work around. I found some code here http://access.mvps.org/access/api/api0042.htm. Since this code is intended to be used in a form I put a button in the report that opens a form and passes in the filepath of the image. Once the form is open it sets the image control to the passed in filepath. Then it executes the copy function and closes itself. This seems to work pretty well.

查看更多
登录 后发表回答