PDA

View Full Version : How to use VBA code to format a screenshot in memory (from clipboard)?



Duvdev
03-25-2014, 07:18 PM
Hello,

I am trying to write several different macros for working with images including cropping, resizing, formatting, etc. I have most code figured out but have one seemingly simple issue. My macros execute perfectly fine as long as I am working with a screenshot or any image already pasted into Word. However, I am trying to figure out how to apply the VBA macro code to a window that I screenshot.

It makes sense to me that either the code would operate directly on the screenshot and paste into Word, or would paste into Word then select the screenshot and run the remainder of the macro code after the fact. I currently use the ‘Selection.Paste’ command to paste screenshots directly into word then force the cursor to “walk” backwards to highlight the screenshot. Sadly this isn’t a great option because my macros mess up other formatting when pasting directly into a table. All issues should be avoided if I can reformat the screenshots then pasting at the very end.

If anyone has any ideas of how to either operate directly on a screenshot in memory, or to force Word to paste and image without unselecting (normal Word paste command pastes the screenshot followed by moving the cursor one space meaning the screenshot is no longer selected).

Seems like this would be one simple line of code or special paste option but I cannot figure it out for the life of me.

Thank you for your time