#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print form

I made userform with an image & 'Print' button for printing the form.
The form gets printed with margin of about 8mm from left & about 5 mm
from top. I tried with shifting the image on the form by about the
margin I intend to have, the result is that the form gets printed at
the desired margins on the print but then the image position seems not
shifted as if. The image gets cut/hidden by the same margings. Say, I
shifted the image on the form by about 25mm from left & 25mm from top.
The same portion of the image (25mm on the left & 25mm on the top) is
hidden in the print.
How to solve this problem?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print form

If change to landscape doesn't help (on alternative), then, since printform
doesn't have any arguments, try adjusting this code to fix your problem.

This was posted by
"Orlando Magalhães Filho"

A while back and seems to work:

In a general module:


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

Sub Test()
UserForm1.Show
End Sub


In the userform module:


Private Sub CommandButton1_Click()
keybd_event VK_SNAPSHOT, 0, 0, 0
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

"Bhuktar S " wrote in message
...
I made userform with an image & 'Print' button for printing the form.
The form gets printed with margin of about 8mm from left & about 5 mm
from top. I tried with shifting the image on the form by about the
margin I intend to have, the result is that the form gets printed at
the desired margins on the print but then the image position seems not
shifted as if. The image gets cut/hidden by the same margings. Say, I
shifted the image on the form by about 25mm from left & 25mm from top.
The same portion of the image (25mm on the left & 25mm on the top) is
hidden in the print.
How to solve this problem?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print form

Here is a version that will capture just the userform: (the previous
captured the whole screen).

Modification of code originally posted by
"Orlando Magalhães Filho"

Modified to capture just the userform (not the whole window).

In a general module:

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 = 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
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
"Tom Ogilvy" wrote in message
...
If change to landscape doesn't help (on alternative), then, since

printform
doesn't have any arguments, try adjusting this code to fix your problem.

This was posted by
"Orlando Magalhães Filho"

A while back and seems to work:

In a general module:


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

Sub Test()
UserForm1.Show
End Sub


In the userform module:


Private Sub CommandButton1_Click()
keybd_event VK_SNAPSHOT, 0, 0, 0
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

"Bhuktar S " wrote in message
...
I made userform with an image & 'Print' button for printing the form.
The form gets printed with margin of about 8mm from left & about 5 mm
from top. I tried with shifting the image on the form by about the
margin I intend to have, the result is that the form gets printed at
the desired margins on the print but then the image position seems not
shifted as if. The image gets cut/hidden by the same margings. Say, I
shifted the image on the form by about 25mm from left & 25mm from top.
The same portion of the image (25mm on the left & 25mm on the top) is
hidden in the print.
How to solve this problem?


---
Message posted from http://www.ExcelForum.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
Print form on screen? Help!! AOU Excel Discussion (Misc queries) 2 January 31st 07 02:11 PM
Form print srv5uk Excel Discussion (Misc queries) 0 July 11th 05 05:34 PM
Print a form Kris Excel Discussion (Misc queries) 4 March 23rd 05 02:03 PM
print a form BlackBlade Excel Programming 0 December 1st 03 07:22 AM
Print a Form Marian[_3_] Excel Programming 0 October 8th 03 09:14 AM


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