print userform (for MVA)

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi,
I'd like print userform and setting (enlarge) leftmargin.
Actually my printout is shift max to left and top.
Is there any solution in VBA (in module or class)?
i have code in body userform now:
Me.PrintForm
but printForm doesn't offer any options.
I find out snap a picture of the userform but how snap the
userform (only) without remain window???

I work in windows and excel 2000.

Any help will be apreciate.

Kind Regards
Mark
 
the code I provided does just take a picture of the userform alone. If you
then pasted it on a worksheet, you will need to manage where you put it,
what the worksheet looks like, and how you define the print area to achieve
your result. Printform alone offers no options.

But I have already told you this in you previous post.
 
Hi Tom!
I know your reply, but I always answer you.
I enjoy you deal with my problem!
I don't know your code (api). I know a bit of VBA.
Actually thanks to You i have pasted whole window
(application and userform), and i'd like only userform. It
isn't dependent on printarea - image paste in worksheet by
your code is snapshot all display in my monitor.
If in snapshot is display all monitor (not olny userform)
how i set printarea autoamticly?
Still i can't snapshot only userform.

Can you resolve my problem or give me any tips?

I work in excel 2k and WIN 2000.

Best Regards
Mark
 
You are correct and I was wrong. Here is a version that will capture just
the userform:

Modification of code originally posted by
"Orlando Magalhães Filho" <[email protected]>

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top