Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel marco to screenshot a user form automatically?
Hello,
I am wondering if it is possible to have Excel take a screen shot of a userform as soon as it loads without using the SendKeys...the reason being I'd like to be able to archive the results (graphically) when a end-user presses a button. Any ideas? Your help is greatly appreciated! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel marco to screenshot a user form automatically?
The Word MVP web site has a short article on screen capture using VBA. The
top half uses SendKeys but below that is an example using API calls which is what you will want to use. http://word.mvps.org/FAQs/MacrosVBA/PrtSc.htm Steve wrote in message ups.com... Hello, I am wondering if it is possible to have Excel take a screen shot of a userform as soon as it loads without using the SendKeys...the reason being I'd like to be able to archive the results (graphically) when a end-user presses a button. Any ideas? Your help is greatly appreciated! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel marco to screenshot a user form automatically?
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 in message ups.com... Hello, I am wondering if it is possible to have Excel take a screen shot of a userform as soon as it loads without using the SendKeys...the reason being I'd like to be able to archive the results (graphically) when a end-user presses a button. Any ideas? Your help is greatly appreciated! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel marco to screenshot a user form automatically?
Tom,
Can you please inform me of where/how you managed to get it just to snap the userform instead of the entire screen? I tried scanning through the code to figure it out but I didn't see it anywhere...maybe is it possible to just snap a FRAME of a userform with this code instead of the entire window? Thanks alot man and to everyone else who helped! -Todd |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel marco to screenshot a user form automatically?
you are simulating Alt+PrintScreen
http://support.microsoft.com/default...b;en-us;153003 I think the best you can do is print the activewindow which in this case is the userform. -- Regards, Tom Ogilvy wrote in message oups.com... Tom, Can you please inform me of where/how you managed to get it just to snap the userform instead of the entire screen? I tried scanning through the code to figure it out but I didn't see it anywhere...maybe is it possible to just snap a FRAME of a userform with this code instead of the entire window? Thanks alot man and to everyone else who helped! -Todd |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
User form caption automatically populate with excel file name | Excel Programming | |||
Ask user for input during marco | Excel Discussion (Misc queries) | |||
ot check out a screenshot of excel 12 | Excel Programming | |||
run a marco automatically | Excel Programming | |||
Automatically including the Form and Code in all the user file | Excel Programming |