Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitmap Ed Excel Discussion (Misc queries) 2 January 26th 07 02:12 AM
UserForm Save Issue DarnTootn Excel Worksheet Functions 0 May 11th 06 05:15 PM
excel userform save problem Pierre via OfficeKB.com[_2_] Excel Programming 3 October 24th 05 07:34 PM
Bitmap manipulation from VBA/VB John Keith[_2_] Excel Programming 2 September 20th 05 07:57 PM
Bitmap Macca Excel Programming 0 October 26th 04 09:43 AM


All times are GMT +1. The time now is 04:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"