Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SZ SZ is offline
external usenet poster
 
Posts: 4
Default Print UserForm A4 size

I have a userForm that is A4 in size and I have tried to use the code
below to print the Active window as my userForm is the 'Active Window'
However the print outcome is 'PRINT SCREEN' with the bottom one third
of my userform not printing at all.
In a Button_Click event I have:-

DoEvents
'Copy the Activewindow to the Clipboard
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
DoEvents
'Copy the Clipboard to the Worksheet
Range(A1").select
ActiveSheet.Paste
DoEvents

Any help TIA.
SZ

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Print UserForm A4 size

Hi SZ,
You should test like that:

Private Declare Function OpenClipboard& Lib "user32" (ByVal hwnd&)
Private Declare Function EmptyClipboard& Lib "user32" ()
Private Declare Function CloseClipboard& Lib "user32" ()
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte _
, ByVal dwFlags&, ByVal dwExtraInfo&)
Private Declare Function GetVersionExA _
Lib "kernel32" (lpVersionInformation _
As OSVERSIONINFO) As Integer

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Private Above4 As Boolean

Private Sub UserForm_Initialize()
Dim OSI As OSVERSIONINFO
OSI.dwOSVersionInfoSize = 148
OSI.szCSDVersion = Space$(128)
Call GetVersionExA(OSI)
Above4 = OSI.dwMajorVersion 4
' your possible code
' ...
End Sub

' Print button
Private Sub CommandButton1_Click()
' Release button
Me.Repaint
OpenClipboard 0&
EmptyClipboard
If Above4 Then
keybd_event VK_SNAPSHOT, 1, 0, 0
Else
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
End If
CloseClipboard
DoEvents
'Me.Hide
Range("A1").Select
ActiveSheet.Paste
' ....
End Sub

Regards,
MP

"SZ" a écrit dans le message de
oups.com...
I have a userForm that is A4 in size and I have tried to use the code
below to print the Active window as my userForm is the 'Active Window'
However the print outcome is 'PRINT SCREEN' with the bottom one third
of my userform not printing at all.
In a Button_Click event I have:-

DoEvents
'Copy the Activewindow to the Clipboard
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
DoEvents
'Copy the Clipboard to the Worksheet
Range(A1").select
ActiveSheet.Paste
DoEvents

Any help TIA.
SZ


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
I am trying to print on legal size paper, i cant set size. Michele Excel Discussion (Misc queries) 1 December 14th 09 02:44 PM
Save as PDF not same size as Print and Print Preview in Excel Jack_Sprat Excel Discussion (Misc queries) 4 April 13th 09 06:38 PM
Zoom size doesn't equal print size vinceh Excel Discussion (Misc queries) 2 August 13th 08 12:03 AM
print view & print, in excel, different size cells buddyorliz Excel Discussion (Misc queries) 3 September 1st 05 01:20 PM
Userform Size Richard Excel Programming 1 May 27th 04 12:16 PM


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