save clipboard as wmf

E

Erich Neuwirth

I need a vba macro to save the clipboard contents as wmf file.
does anybody have code for doing this?
 
B

BrianB

Cannot do the .wmf file because MS Paint will only save a .bmp file
However this macro should give you an idea how to do it with you
application. You will probably have quite a bit of tweaking to do t
get it to work. Save your macro often.

Copy the picture in Excel and run the macro. After opening MSPaint wit
Shell(), it mimics the menu keystrokes required to paste the pictur
from the clipboard, save the file, and close MS Paint.

The macro tends to run too fast so delays have been put in to allo
time for things to happen in Paint as a result of SendKeys, otherwis
Sendkeys tries to send to Excel - often with odd results.

Be patient, and allow time for the macro to complete before doin
anything.

'---------------------------------------------
Sub SavePicture()
Dim MSPaint As String
Dim MyFileName As String
Dim Alt As String
'----------------------------
MyFileName = "Myfile.bmp"
'----------------------------
Alt = "%"
MSPaint = "C:\WINNT\system32\mspaint.exe"
retval = Shell(MSPaint, 1)
'- paste --------------------------
SendKeys Alt & "E", True ' edit
SendKeys "P", True 'paste
Application.Wait Now + TimeValue("00:00:02")
'- save file ------------------------
SendKeys Alt & "F" ' file
Application.Wait Now + TimeValue("00:00:01")
'-
SendKeys "A", True ' saveas
Application.Wait Now + TimeValue("00:00:01")
'-
SendKeys MyFileName, True 'file name
Application.Wait Now + TimeValue("00:00:02")
'-
SendKeys Alt & "S", True
DoEvents
Application.Wait Now + TimeValue("00:00:5")
'- close ----------------------------
SendKeys Alt & "{F4}", True
DoEvents
MsgBox ("File Saved.")
End Sub
'-- eop --------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top