Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Capture a part of a screen
Hi
I've found macros that enable to capture the whole screen Looking for a macro that enables to capture only a part of the screen Please help Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Capture a part of a screen
do you mean like Alt+[Print Scrn] ? why don't you use SendKeys
"benitAAvi" wrote: Hi I've found macros that enable to capture the whole screen Looking for a macro that enables to capture only a part of the screen Please help Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Capture a part of a screen
Hi Basically, it is what i'm looking for but i want to capture only a part of the screen and not all of it Thanks *** Sent via Developersdex http://www.developersdex.com *** |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Capture a part of a screen
Hi benitAAvi,
In a standard module: Option Explicit ' Object dimensions Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function _ GetActiveWindow& Lib "user32" () Private Declare Sub GetWindowRect Lib _ "user32" (ByVal hWnd&, lpRect As RECT) Private Declare Function _ GetDesktopWindow& Lib "user32" () ' Clipboard manipulation Private Declare Function _ OpenClipboard& Lib "user32" (ByVal hWnd&) Private Declare Function _ CloseClipboard& Lib "user32" () Private Declare Function SetClipboardData& _ Lib "user32" (ByVal wFormat&, ByVal hMem&) Private Declare Function _ EmptyClipboard& Lib "user32" () ' Bitmap creation Private Declare Function GetDC& _ Lib "user32" (ByVal hWnd&) Private Declare Function _ CreateCompatibleDC& Lib "gdi32" (ByVal hDC&) Private Declare Function CreateCompatibleBitmap& _ Lib "gdi32" (ByVal hDC&, ByVal nWidth& _ , ByVal nHeight&) Private Declare Function SelectObject& _ Lib "gdi32" (ByVal hDC&, ByVal hObject&) Private Declare Function BitBlt& Lib "gdi32" _ (ByVal hDestDC&, ByVal X&, ByVal Y& _ , ByVal nWidth&, ByVal nHeight&, ByVal hSrcDC& _ , ByVal XSrc&, ByVal YSrc&, ByVal dwRop&) Private Declare Function ReleaseDC& _ Lib "user32" (ByVal hWnd&, ByVal hDC&) Private Declare Function DeleteDC& _ Lib "gdi32" (ByVal hDC&) ' Picture creation Private Type PicBmp Size As Long Type As Long hBmp As Long hPal As Long Reserved As Long End Type Private Type Guid Data1 As Long Data2 As Integer Data3 As Integer Data4(0 To 7) As Byte End Type Private Declare Function OleCreatePictureIndirect _ Lib "olepro32.dll" (PicDesc As PicBmp _ , RefIID As Guid, ByVal fPictureOwnsHandle As Long _ , IPic As IPicture) As Long ' Object (UserForm, FullScreen, etc.): Sub ScreenObjectCopy() Dim hPtr&, R As RECT Call GetWindowRect(GetActiveWindow, R) hPtr = CreateBitmap(R.Right - R.Left _ , R.Bottom - R.Top, R.Left, R.Top) If hPtr = 0 Then Exit Sub ' Save image on disk 'SavePicture CreatePicture(hPtr), "c:\mytest.bmp" ActiveSheet.Paste End Sub Sub ScreenPartCopy() Dim hPtr& ' Pixels coordinates (Width, Height, Left, Top) hPtr = CreateBitmap(250, 150) If hPtr = 0 Then Exit Sub ' Save image on disk 'SavePicture CreatePicture(hPtr), "c:\mytest.bmp" ActiveSheet.Paste End Sub Private Function CreateBitmap&(ByVal W& _ , ByVal H&, Optional L& = 0, Optional T& = 0) Dim hWnd&, hBitmap&, hDC&, hDCMem& hWnd = GetDesktopWindow() ' Get Desktop device context and allocate memory hDC = GetDC(hWnd) hDCMem = CreateCompatibleDC(hDC) hBitmap = CreateCompatibleBitmap(hDC, W, H) If hBitmap Then Call SelectObject(hDCMem, hBitmap) ' Copy Desktop bitmap to memory location ' based on object coordinates. Call BitBlt(hDCMem, 0, 0, W, H, hDC, L, T, &HCC0020) ' Set up Clipboard and copy bitmap Call OpenClipboard(hWnd) Call EmptyClipboard CreateBitmap = SetClipboardData(2, hBitmap) Call CloseClipboard End If ' Clean up handles Call DeleteDC(hDCMem) Call ReleaseDC(hWnd, hDC) End Function Private Function CreatePicture(ByVal hBmp&) As IPicture Dim Ret&, Pic As PicBmp, IPic As IPicture, IID As Guid With IID ..Data1 = &H20400 ..Data4(0) = &HC0 ..Data4(7) = &H46 End With With Pic ..Size = Len(Pic) ..Type = 1 ..hBmp = hBmp End With Ret = OleCreatePictureIndirect(Pic, IID, 1, IPic) Set CreatePicture = IPic End Function ' ---------------------------------- ' Form copy with button on it 'Private Sub CommandButton1_Click() 'Me.Repaint 'ScreenObjectCopy 'End Sub Regards, MP "benitAAvi" a écrit dans le message de news: ... Hi I've found macros that enable to capture the whole screen Looking for a macro that enables to capture only a part of the screen Please help Thanks |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Capture a part of a screen
Hi
Which part? Part of the Excel workbook, another application's window, what ? Best wishes Harald "Avi Benita" skrev i melding ... Hi Basically, it is what i'm looking for but i want to capture only a part of the screen and not all of it Thanks *** Sent via Developersdex http://www.developersdex.com *** |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Capture a part of a screen
Use Print Screen button to capture entire screen, which may be
the only way to capture an expanded menu. Since hitting any key such as Alt or Ctrl will lose the expanded menu. Use Alt+Print_Screen to capture the active window. To cut down on what you have captured and placed into a picture file (.jpg, jpeg, .bmp, .gif, ...etc.) you can use an image editor one such free editor is IrfanView (irfanview.com). I also use SnagIT which is not free. Results can be seen on many pages i.e. http://www.mvps.org/dmcritchie/excel...dow.htm#minmax Since this is the programming group that may not be what you were looking for. Michel Pierron certainly supplied a programming solution but there is no writeup concerning the functions and macros. I'd say it really needs a web page. Harold Staff provided the information in XL2GIF routine and manipulations http://www.mvps.org/dmcritchie/excel/xl2gif.htm which allows you to select a range of cells and create a picture of the cells (no pictures copied from the range). --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "Avi Benita" wrote in message ... Hi Basically, it is what i'm looking for but i want to capture only a part of the screen and not all of it Thanks *** Sent via Developersdex http://www.developersdex.com *** |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Capture a part of a screen
i want to capture a Part of Excel Workbook which contains a certain activeX picture that does not respond to the usual Copy image command, but does respond to Capture screen Thanks "Harald Staff" wrote in message ... Hi Which part? Part of the Excel workbook, another application's window, what ? Best wishes Harald "Avi Benita" skrev i melding ... Hi Basically, it is what i'm looking for but i want to capture only a part of the screen and not all of it Thanks *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel screen capture to capture cells and row and column headings | Excel Discussion (Misc queries) | |||
screen capture of page | Excel Worksheet Functions | |||
Screen shots capture | Excel Programming | |||
Need Help! VBA screen capture question | Excel Programming | |||
How to capture screen through VBA? | Excel Programming |