?
Solved

make a forms width fit printout

Posted on 2014-10-11
10
Medium Priority
?
84 Views
Last Modified: 2014-10-13
The form is wider than a sheet of paper and not ver tall
I have form that i am trying to avoid making everthing smaller so it can be printed on one sheet of paper
way i see it their are 3 possible solutations
1. redraw all the controls to make them closer together thus making the form more narrow.
Trying to avoid this as many users are using high resolutation and am not sure it will still fit
2. Print the form in Landscape.
Have read where not all printers support Landscape and am not sure if printform can print Landscape
3. Create another form just for printing and copy all the data
Maybe their is another method i have not listed.
Which way would be the best ? and is there another way ?Print problem
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40375121
Try this project. If you need help in adding its code to your project please let me know.
Wide.zip
0
 

Author Comment

by:isnoend2001
ID: 40375210
Thanks martinLiss, but nothing happens when i click the buttons and Form1 was not added to the project
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 40375248
Here is a corrected zip file.
Wide.zip
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:isnoend2001
ID: 40375262
Thanks MartinLiss
I added to print to pdf, so not to waste paper
I will try to modify my project using your code
First thought
does the picturebox cover the whole form with the controls add to the picturebox ?
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40376141
does the picturebox cover the whole form with the controls add to the picturebox ?
Sorry but I'm not sure what that means. In any case you could probably have the picturebox be invisible and still print its contents. If you post a zip of your project (or even just the bids form) then I can probably incorporate the code for you.
0
 

Author Comment

by:isnoend2001
ID: 40376230
Thanks martinLiss
EE would not open earlier tried 4-5 times
I attached the zip
I added a print button to get the printers
I always print to pdf when testing
GetBids.zip
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40377516
This might take an hour or this might take a day, but I'll get back to you.
0
 

Author Comment

by:isnoend2001
ID: 40377750
no problem
Thank you
0
 

Author Comment

by:isnoend2001
ID: 40378050
Hi MartinLiss i got this code from another site

in bas module
Option Explicit

Private Type GUID
    Data1    As Long
    Data2    As Integer
    Data3    As Integer
    Data4(7) As Byte
End Type

Private Type PicBmp
    Size As Long
    Type As Long
    hBitmap As Long
    hPal As Long
    Reserved As Long
End Type

Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, iPic As IPicture) As Long



Public Function FormToPrint(MyForm As Form) As Picture
Dim FormWidth     As Long
Dim FormHeight    As Long
Dim SourceDC      As Long
Dim MemoryDC      As Long
Dim hBitmap       As Long
Dim hBitmapTemp   As Long

With MyForm
  FormWidth = .ScaleX(.ScaleWidth, .ScaleMode, vbPixels)
  FormHeight = .ScaleY(.ScaleHeight, .ScaleMode, vbPixels)
End With

  SourceDC = MyForm.hdc
  MemoryDC = CreateCompatibleDC(SourceDC)
  hBitmap = CreateCompatibleBitmap(SourceDC, FormWidth, FormHeight)
  hBitmapTemp = SelectObject(MemoryDC, hBitmap)

  BitBlt MemoryDC, 0, 0, FormWidth, FormHeight, SourceDC, 0, 0, vbSrcCopy

  hBitmap = SelectObject(MemoryDC, hBitmapTemp)
 
  DeleteDC MemoryDC
  ReleaseDC MyForm.hwnd, SourceDC

Set FormToPrint = CreateBitmap(hBitmap)
End Function


Private Function CreateBitmap(ByVal hBitmap As Long) As Picture
Dim PIC           As PicBmp
Dim iPic          As IPicture
Dim IID_IDispatch As GUID

  With IID_IDispatch
      .Data1 = &H20400
      .Data4(0) = &HC0
      .Data4(7) = &H46
  End With
 
  With PIC
      .Size = Len(PIC)
      .Type = vbPicTypeBitmap
      .hBitmap = hBitmap
  End With
 
  OleCreatePictureIndirect PIC, IID_IDispatch, 1, iPic

Set CreateBitmap = iPic
End Function


Calling the function:

Sub PrintGetBids()
 Dim Percentage As Double

Percentage = 75 '50 'Set Image scale %
Percentage = Percentage / 100

Printer.ScaleMode = vbTwips
frmPrintGetBids.ScaleHeight
Printer.PaintPicture FormToPrint(frmPrintGetBids), 0, 0, Percentage * frmPrintGetBids.ScaleWidth, Percentage *
Printer.EndDoc
End Sub


This seems to work for the sizing, however Ihave ran into another problem
I will post it in another question
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40378135
Before you do that try this project. (You'll need to add the dat file).
Q-28535877.zip
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question