Saving a pic
hey
i really need help with this, i have posted in tons of forums and the descussion groups, no replies! gar
lol, well i have this macro in excel 2003 and it has a userform and there are a few elements (3 pictures, 3 text boxes) that get modified during the macro then i need to kinda merge them and save it as one picture, can a macro do that?
any help would be great thx
[441 byte] By [
Edday] at [2008-1-7]
Here is some code to save the userform as a image to the worksheet. You could then crop the image.
Posted by Orlando Magalh?es Filho and modified by Tom Ogilvy
Modification of code originally posted by
"Orlando Magalh?es Filho" <orlan...@geocities.com.br>
Modified to capture just the userform (not the whole window).
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
'Public Const VK_SNAPSHOT = &H2C
Public Const VK_SNAPSHOT = 44
Public Const VK_LMENU = 164
Public Const KEYEVENTF_KEYUP = 2
Public Const KEYEVENTF_EXTENDEDKEY = 1
Sub Test()
UserForm1.Show
End Sub
In the userform module:
Private Sub CommandButton1_Click()
' keybd_event VK_SNAPSHOT, 0, 0, 0
DoEvents
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY, 0 ' key down
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
DoEvents
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial Format:="Bitmap", _
Link:=False, DisplayAsIcon:=False
End Sub
hey again
thx for code looks exactly what i want except when i put it in to test it, it just somes with the compile error:
"Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules"
it says that on all the lines with "Public Const" at the start.
how could i fix it?
but apart from that, Andy, you are a life saver!