Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
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
Excel screen capture to capture cells and row and column headings jayray Excel Discussion (Misc queries) 5 November 2nd 07 11:01 PM
screen capture of page Juco Excel Worksheet Functions 2 March 13th 05 12:50 AM
Screen shots capture matt dunbar Excel Programming 2 October 8th 04 03:03 PM
Need Help! VBA screen capture question Jon Peltier[_8_] Excel Programming 0 July 29th 04 11:40 PM
How to capture screen through VBA? Bill Choy[_2_] Excel Programming 3 July 23rd 04 05:00 AM


All times are GMT +1. The time now is 02:38 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"