Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save Userform as bitmap
Hi,
Is there a simple way to save a picture of a userform as a bitmap (or jpeg,gif, etc.) programatically? I would prefer to only have the userform in the picture, not a full screen capture. I'm using excel 2003 and have a userform with a bunch of shapes on it. Thanks a lot, Puck312 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save Userform as bitmap
You can probably modify this code to get what you want:
Modification of code originally posted by "Orlando Magalhães Filho" 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 Workbooks.Add Application.Wait Now + TimeValue("00:00:01") ActiveSheet.PasteSpecial Format:="Bitmap", _ Link:=False, DisplayAsIcon:=False ActiveSheet.Range("A1").Select ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Close False End Sub -- Regards, Tom Ogilvy " wrote: Hi, Is there a simple way to save a picture of a userform as a bitmap (or jpeg,gif, etc.) programatically? I would prefer to only have the userform in the picture, not a full screen capture. I'm using excel 2003 and have a userform with a bunch of shapes on it. Thanks a lot, Puck312 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save Userform as bitmap
I can manage to save the userform snapshot to the clipboard, but is
there a way to save the clipboard image to some sort of image file (jpg, bmp, etc.) instead of pasting to the worksheet? That is the part that I am getting stuck on. The form displays the arrangement of a bunch of boxes on shelves and shows how they are moved around, step by step. So, when the user hits a command button, the form updates to show the new arrangement. The point of taking the snapshot is to get a picture at each step and get the pictures imported into a powerpoint presentation in the correct order. I've found a thread that shows how to import one snapshot into a slide in a newly created powerpoint presentation, but if I try to iterate through the steps, the snapshot gets messed up after the first one. I think it has to do with which window has the focus, but I'm not too sure how the api above works, just that it does. In light of this problem, I've changed my approach to to save a snapshot of each step as some type of image file and then I can import them into powerpoint later. Plus it would be nice to have the image files saved into a folder instead of directly importing them from the snapshot. But, once again, I'm stuck. How do I save a clipboard image to some port of image file? Thanks in advance, Puck312 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Bitmap | Excel Discussion (Misc queries) | |||
UserForm Save Issue | Excel Worksheet Functions | |||
excel userform save problem | Excel Programming | |||
Bitmap manipulation from VBA/VB | Excel Programming | |||
Bitmap | Excel Programming |