Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
User form caption automatically populate with excel file name Steve Excel Programming 2 October 17th 06 11:44 PM
Ask user for input during marco TSS Excel Discussion (Misc queries) 1 November 16th 05 10:57 PM
ot check out a screenshot of excel 12 Gary Keramidas[_2_] Excel Programming 3 September 14th 05 03:39 AM
run a marco automatically Dennis Cheung[_2_] Excel Programming 5 May 13th 05 06:24 AM
Automatically including the Form and Code in all the user file ssexcel[_5_] Excel Programming 3 November 13th 03 07:33 AM


All times are GMT +1. The time now is 02:30 AM.

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"