Print Page Size Help
i am using printer.print
how do i tell the computer i want to print to Legal size????
Printer.PaperSize
but what is the answer for legal?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Print Images That Fit To The Page Size Specified In Print Common Dialog?
i need some help in printing the whole image tat fit onto the paper size i specified in Print Common Dialog. I hav a PictureBox array & each PictureBox contains a smaller Picturebox inside. For example : Picture1(index) has a smaller Picture2(index) inside. There are vertical & horizontal scrollbars next to each Picture1(index).
i already hav the basic Print Common Dialog code below. Here's the problem -> I can print out the pictures displayed inside Picture2(index) but the printout will turn out truncated or just part of the whole picture when im printing to a 4R photo size for example and the image displayed in Picture2(index) is larger then the bounding Picture1(index) & i need to use the scrollbars to scroll and view the other portions of the image.
So how to modify the code below to print out the whole image tat fit nicely to the paper size i specified. Thanxs.
'---------------------------------------------------------------------
'CODE
'---------------------------------------------------------------------
CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.Action = 5 ' Start the Print Common Dialog
If (Err.Number = cdlCancel) Then Exit Sub
'when Cancel is pressed, exit subroutine
'Code to print the array here
For Pics = Picture2.LBound To Picture2.UBound
If Picture2(Pics).Picture > 0 Then ' If the PictureBox is not empty
Printer.PaintPicture Picture2(Pics).Picture, 0, 0
Printer.EndDoc
End If
Next
'---------------------------------------------------------------------
Print Dialog & Page Size
Can the page size progerty be reteived from the
Print Dialog.
I can get Orientation, Copies, etc but there
doesn't seem to be a paper size property even
though you can set it by clicking Properties
when the Print Dialog is displayed.
Thanks in advance
SeanR
Print Custom Page Size In Win 2000
I need to print continuous 5 1/2 inch forms on an OKIDATA 390 Plus and OKIDATA 393 Turbo printer from a VB application in Windows 2000. I got code from microsoft.com HOWTO Q282474 and incorporated it into my VB application so that it selects a custom size form before printing. Sometimes it works and sometimes it just doesn't seem to be using the form even though I have watched it select the form in the debugger. I haven't been able yet to isolate all the factors coming into play but while I am trying to do that, is there anyone who has worked with printing custom page sizes and knows some rules of thumb...or is there another way to print a 5 1/2 inch form?
Thanks a lot
Tina D
Datareport Print To Specific Printer Or Change Page Size
Sorry for fad English
i have a datareport thats print a ticket (1/4 A4) .
1.- im defined a specific papersize in the printer settings (control pannel) and seting it as default paper
2.- the ticket printing its OK
3.- i need to print too a day report into A4 paper...i receive "report width is larger than the paper width"
4.- im trying to set the papersize before print the dtareport (print.papersize = vbPRPSA4) (dont works)
5.- im trying to send print to another printer (copy) with A4 paper setting as default (dont works)
6.- im triying to show printer dialog to select the oter printer or change the paper settings (datareport.printreport true) (dont works)
PLEASE HELP ME !
** win 2K
** epson lx-300+
RESOLVED - Can't Get Page Setup Dialog To Show Page Size Correctly
Hey guys and gals, I am hoping someone will have an idea on this one . . .
I am trying to show the page setup dialog and prepopulate the values of the page setup dialog before it is shown. All of the form pre-population seems to work except paper size. I can retrieve paper size just fine after the user clicks ok on the form, I just can't seem to set it before the form is populated.
I created a tiny test app to illustrate my problem.
VB Code:
' on a formOption Explicit Private Sub Command1_Click() With Printer' Height & Width; Printer object — the physical dimensions' of the paper set up for the printing device; not available' at design time. If set at run time, values in these properties' are used instead of the setting of the PaperSize property.' .Width = 14' .Height = 8.5 .PaperSize = vbPRPSLegal .Orientation = vbPRORLandscape End With ShowPageSetupDlg MeEnd Sub '********************************************************************' IN A MODULE! Option Explicit Const CCHDEVICENAME = 32Const CCHFORMNAME = 32Const GMEM_MOVEABLE = &H2Const GMEM_ZEROINIT = &H40Const DM_DUPLEX = &H1000&Const DM_ORIENTATION = &H1&Const PSD_MARGINS = &H2Const PSD_DISABLEPRINTER = &H20Const PSD_INTHOUSANDTHSOFINCHES As Long = &H4Const PSD_DISABLEPAPER As Long = &H200 Private Declare Function PageSetupDlg Lib "comdlg32.dll" _ Alias "PageSetupDlgA" (pPagesetupdlg As PageSetupDlg) As Long Private Declare Sub CopyMemory Lib "kernel32" _ Alias "RtlMoveMemory" _ (hpvDest As Any, _ hpvSource As Any, _ ByVal cbCopy As Long) Private Declare Function GlobalLock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32" _ (ByVal wFlags As Long, _ ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32" _ (ByVal hMem As Long) As Long Private Type POINTAPI x As Long Y As LongEnd TypePrivate Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Type PageSetupDlg lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long flags As Long ptPaperSize As POINTAPI rtMinMargin As RECT rtMargin As RECT hInstance As Long lCustData As Long lpfnPageSetupHook As Long lpfnPagePaintHook As Long lpPageSetupTemplateName As String hPageSetupTemplate As LongEnd TypePrivate Type DEVMODE_TYPE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTToption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As LongEnd Type Public Function ShowPageSetupDlg(frm As Form) As Boolean Dim DevMode As DEVMODE_TYPE Dim lpDevMode As Long Dim m_PSD As PageSetupDlg Dim bReturn As Integer On Error Resume Next 'Set the current orientation and duplex setting DevMode.dmDeviceName = Printer.DeviceName DevMode.dmFields = DM_ORIENTATION Or DM_DUPLEX' DevMode.dmPaperWidth = Printer.Width' DevMode.dmPaperLength = Printer.Height DevMode.dmOrientation = Printer.Orientation DevMode.dmPaperSize = Printer.PaperSize DevMode.dmDuplex = Printer.Duplex DevMode.dmSize = Len(DevMode) On Error GoTo 0 'Allocate memory for the initialization hDevMode structure 'and copy the settings gathered above into this memory m_PSD.hDevMode = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, Len(DevMode)) lpDevMode = GlobalLock(m_PSD.hDevMode) If lpDevMode > 0 Then CopyMemory ByVal lpDevMode, DevMode, Len(DevMode) bReturn = GlobalUnlock(m_PSD.hDevMode) End If With m_PSD .rtMargin.Top = 0.5 * 1000 .rtMargin.Bottom = 0.5 * 1000 .rtMargin.Left = 0.5 * 1000 .rtMargin.Right = 0.5 * 1000 .ptPaperSize.x = 14 * 1000 .ptPaperSize.Y = 8.5 * 1000 .lStructSize = Len(m_PSD) 'Set the structure size .hwndOwner = frm.hWnd 'Set the owner window .hInstance = App.hInstance 'Set the application instance .flags = PSD_MARGINS Or PSD_DISABLEPRINTER Or PSD_INTHOUSANDTHSOFINCHES End With 'Show the pagesetup dialog If PageSetupDlg(m_PSD) Then ShowPageSetupDlg = True' sngMarginTop = (m_PSD.rtMargin.Top) / 1000' sngMarginBottom = (m_PSD.rtMargin.Bottom) / 1000' sngMarginLeft = (m_PSD.rtMargin.Left) / 1000' sngMarginRight = (m_PSD.rtMargin.Right) / 1000' sngPageW = (m_PSD.ptPaperSize.x) / 1000' sngPageH = (m_PSD.ptPaperSize.Y) / 1000 ' Get DEVMODE structure from PRINTDLG lpDevMode = GlobalLock(m_PSD.hDevMode) CopyMemory DevMode, ByVal lpDevMode, Len(DevMode) Call GlobalUnlock(m_PSD.hDevMode) ' Set default printer properties On Error Resume Next If Not (Printer Is Nothing) Then Printer.Copies = DevMode.dmCopies Printer.Orientation = DevMode.dmOrientation Printer.PaperSize = DevMode.dmPaperSize' lPaperSize = DevMode.dmPaperSize Printer.PrintQuality = DevMode.dmPrintQuality End If On Error GoTo 0 End IfEnd Function
Thanks in advance for any insight!
Problem With Print, Page Setup, And Print Preview In A Text Editor...
Yes, I have another question.
When I use these exact same functions (with WebBrowser.ExecWB in place of txtScrapbook.Text) in my web browser, it works perfectly. But when I use them in reference to a text box, it doesn't.
Can you tell me where the problem lies, or give me an alternative method? I have a common dialog box already for other functions, so feel free to make use of it if you need to. Thanks.
Code:Private Sub PageSetup_Click()
txtScrapbook.Text OLECMDID_PAGESETUP, OLECMDEXECOPT_DODEFAULT
'opens page setup dialog
End Sub
Private Sub Print_Click()
txtScrapbook.Text OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
'opens common dialog box prompting user to print current web page/parts of current web page
End Sub
Private Sub PrintPreview_Click()
txtScrapbook.Text OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT
'opens print preview dialog
End Sub
Print Picture Box (print A Form That Is Too Large For The Screen Or Page)
I got a picture box (Picture1), which contain several picture box'es, labels and
Flex Grid tables, -which I would like to print. Picture1 is quite high (higher than the screen). I found some code that i modified, but the printing only get the labels proper. The Flex Grids and picture box'es only show the border, and not the contents.
Code:Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4& ' Draw the window's client area.
Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows.
Private Const PRF_OWNED = &H20& ' Draw all owned windows.
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Print_Click()
Dim rv As Long
Me.ScaleMode = vbTwips ' default
With Picture2
.Top = Picture1.Top
.Left = Picture1.Left
.Width = Picture1.Width
.Height = Picture1.Height
End With
Me.Visible = True
DoEvents
Picture1.SetFocus
Picture2.AutoRedraw = True
rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Picture2.Picture = Picture2.Image
Picture2.AutoRedraw = False
Printer.Print ""
Printer.PaintPicture Picture2.Picture, 0, 0
Printer.EndDoc
End Sub
Edited by - Zigar on 11/27/2003 3:31:21 AM
Print Column Header On Each Print Out Page
I am trying to put the header of each column on each print out page.
Right now I have it only appearing on the first page of my printouts.
How do you do that in Excel 2003?
HELP Print Listview Print To Many Page
HI
I am using this to print Listview
When I print 1 page then it is ok but
if data from Listview go on 3 or 4 page then fyrst page is ok
efter fyrst page I only get 1 data on on each page
so this can be many page
Can somone help me what is wrong in this ??
Printer.Font = "Tahoma"
Printer.FontBold = True
Printer.FontUnderline = False
Printer.FontSize = 10
Printer.Print "Print from listview"
Printer.FontUnderline = False
Printer.Print vbNewLine
Printer.CurrentX = 1440
Printer.CurrentY = 1440
PrintListView lvwDataCopy
Printer.EndDoc
Private Sub PrintListView(lvw As ListView)
Const Margin = 60
Const COL_MARGIN = 240
Dim ymin As Single
Dim ymax As Single
Dim xmin As Single
Dim xmax As Single
Dim num_cols As Integer
Dim column_header As ColumnHeader
Dim list_item As ListItem
Dim i As Integer
Dim num_subitems As Integer
Dim col_wid() As Single
Dim X As Single
Dim y As Single
Dim line_hgt As Single
xmin = Printer.CurrentX
ymin = Printer.CurrentY
' ******************
' Get column widths.
num_cols = lvw.ColumnHeaders.Count
ReDim col_wid(1 To num_cols)
' Check the column headers.
For i = 1 To num_cols
col_wid(i) = _
Printer.TextWidth(lvw.ColumnHeaders(i).Text)
Next i
' Check the items.
num_subitems = num_cols - 1
For Each list_item In lvw.ListItems
' Check the item.
If col_wid(1) < Printer.TextWidth(list_item.Text) _
Then _
col_wid(1) = Printer.TextWidth(list_item.Text)
' Check the subitems.
For i = 1 To num_subitems
If col_wid(i + 1) < _
Printer.TextWidth(list_item.SubItems(i)) _
Then _
col_wid(i + 1) = _
Printer.TextWidth(list_item.SubItems(i))
Next i
Next list_item
' Add a column margin.
For i = 1 To num_cols
col_wid(i) = col_wid(i) + COL_MARGIN
Next i
' *************************
' Print the column headers.
Printer.CurrentY = ymin + Margin
Printer.CurrentX = xmin + Margin
X = xmin + Margin
For i = 1 To num_cols
Printer.CurrentX = X
Printer.Print FittedText( _
lvw.ColumnHeaders(i).Text, col_wid(i));
X = X + col_wid(i)
Next i
xmax = X + Margin
Printer.Print
line_hgt = Printer.TextHeight("X")
y = Printer.CurrentY + line_hgt / 2
Printer.Line (xmin, y)-(xmax, y)
y = y + line_hgt / 2
' Print the rows.
num_subitems = num_cols - 1
For Each list_item In lvw.ListItems
X = xmin + Margin
' Print the item.
Printer.CurrentX = X
Printer.CurrentY = y
Printer.Print FittedText( _
list_item.Text, col_wid(1));
X = X + col_wid(1)
' Print the subitems.
For i = 1 To num_subitems
Printer.CurrentX = X
Printer.Print FittedText( _
list_item.SubItems(i), col_wid(i + 1));
X = X + col_wid(i + 1)
Next i
y = y + line_hgt * 1.5
Next list_item
ymax = y
' Draw lines around it all.
Printer.Line (xmin, ymin)-(xmax, ymax), , B
X = xmin + Margin / 2
For i = 1 To num_cols - 1
X = X + col_wid(i)
Printer.Line (X, ymin)-(X, ymax)
Next i
End Sub
Print A Page Without My Print Button!!!
My question concern my web page:
How can i print an html page without it's print button.
I figure out how to hide the button when pressed(with layers)
but when it's finish printing or the user cancel,
how can i make the button visible,i know how but on
what event.
some1 have an idea??
Page Size
How do you set the printers page size?
PDF Page Size
I want to obtain Page Size of PDF Documents(not file size in kb).
Is there a way to obtain this in VB? I do not want Adobe dependency.
Other dependency is fine if we can have full source code.
Thanks in advance.
ADS Page Size
Hi,
I have a program which is intended to return a list of group members from a win2000 active directory group. It works fine, except that I am hitting the 1000 object page size limit.
I know how to get around this to return > 1000 objects, but am baffled on how to get > 1000 items from the array which is returned as a property of the group object (currently it just tells me there are 1000 members whenever there are > 1000).
PS. Wasn't sure which forum this should be in, so.....
Page Size
I am working on a simple Word processor using richTextBox
Is there any way of making sure that
my Richtextbox is always 8.5 X 11 paper size
and olso have a 1" Top, left, right, and bottom
margin
thanks in advance.
Custom Page Size?!?!
when i open a word document from my application i get a custom paper size set.
is there a way to change this?
Papa.
Re-size Metafile To Fit On One Page
Have some code that pastes certain ranges from Excel into Word as metafiles. Was hoping someone could help me with some code to the effect of - If the number of records in the copied range is greater than a defined variable, then re-size (with proportions maintained) the metafile to fit on one page.
Thanks in advance for any assistance.
Page Size Of A Record Set
hi all:
"The PageSize property sets or returns a long value that indicates the maximum number of records allowed on a single page of a Recordset object. "
now...can some body tell me what exactly is the definition of a "page" of a Recordset?
thanks
How To Set Page Size On Run Time
hello friends.
i m having problem .. i want to change size of page legal to A4 or Envelop4 etc ... what is the correct codeing ...... and i also want to call scanner at runtime ..
plz help me
Printer Page Size
Hello all,
I am working with the HP DesignJet 1050c (driver version 4.00) on windows NT 4.0 (sp6) and I would like to set the paper size programmatically (VB 6.0 or VBA) to a non standard format like 50 x 50 mm for example (changes I maid should remain for other programs).
The code below is an example from Microsoft. I have tried it with all of my printers and it never works.
Does somebody knows what’s wrong with it ?
Thanks in advance.
'Form Code
Private Sub Command1_Click()
SetPrinter Me.hWnd
PrintTest
End Sub
'Module code
Option Explicit
Public Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" _
(ByVal pPrinterName As String, phPrinter As Long, ByVal pDefault As Long) As Long
Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Public Declare Function DocumentProperties Lib "winspool.drv" _
Alias "DocumentPropertiesA" (ByVal hWnd As Long, _
ByVal hPrinter As Long, ByVal pDeviceName As String, _
pDevModeOutput As Any, pDevModeInput As Any, ByVal fMode As Long) _
As Long
Public Declare Function ResetDC Lib "gdi32" Alias "ResetDCA" _
(ByVal hdc As Long, lpInitData As Any) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
' Constants for DEVMODE
Public Const CCHFORMNAME = 32
Public Const CCHDEVICENAME = 32
Public Const DM_FORMNAME As Long = &H10000
Public Const DM_ORIENTATION = &H1&
Public Const DM_PAPERSIZE = &H2&
Public Const DM_PAPERLENGTH = &H4&
Public Const DM_PAPERWIDTH = &H8&
' Constants for DocumentProperties() call
Public Const DM_MODIFY = 8
Public Const DM_IN_BUFFER = DM_MODIFY
Public Const DM_COPY = 2
Public Const DM_OUT_BUFFER = DM_COPY
Public Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public Function SetPrinter(MyhWnd As Long) As Integer
Dim nSize As Long ' Size of DEVMODE
Dim pDevMode As DEVMODE
Dim PrinterHandle As Long ' Handle to printer
Dim hPrtDC As Long ' Handle to Printer DC
Dim PrinterName As String
Dim aDevMode() As Byte ' Working DEVMODE
PrinterName = Printer.DeviceName ' Current printer
hPrtDC = Printer.hdc ' hDC for current Printer
' Get a handle to the printer.
If OpenPrinter(PrinterName, PrinterHandle, 0&) Then
' Retrieve the size of the DEVMODE.
nSize = DocumentProperties(MyhWnd, PrinterHandle, PrinterName, 0&, 0&, 0&)
' Reserve memory for the actual size of the DEVMODE.
ReDim aDevMode(1 To nSize)
' Fill the DEVMODE from the printer.
nSize = DocumentProperties(MyhWnd, PrinterHandle, PrinterName, aDevMode(1), 0&, DM_OUT_BUFFER)
' Copy the Public (predefined) portion of the DEVMODE.
Call CopyMemory(pDevMode, aDevMode(1), Len(pDevMode))
' Change the appropriate member in the DevMode.
pDevMode.dmFields = pDevMode.dmFields Or DM_PAPERSIZE Or DM_PAPERLENGTH Or DM_PAPERWIDTH
pDevMode.dmFields = pDevMode.dmFields And (Not DM_FORMNAME)
' this needs to be 256 + (formlength) + (0 or 1) where 0=die cut 1=continuous
' the example here sets form length (height) to 1" = 25.4mm
pDevMode.dmPaperSize = 256 + (254) + 1
' this needs to be the form length again (in tenths of mm)
pDevMode.dmPaperLength = 254
' the form width in tenths of mm
pDevMode.dmPaperWidth = 4 * 254
' Copy your changes back, then update DEVMODE.
Call CopyMemory(aDevMode(1), pDevMode, Len(pDevMode))
nSize = DocumentProperties(MyhWnd, PrinterHandle, PrinterName, aDevMode(1), aDevMode(1), DM_IN_BUFFER Or DM_OUT_BUFFER)
nSize = ResetDC(hPrtDC, aDevMode(1)) ' Reset the DEVMODE for the DC.
' Close the handle when you are finished with it.
ClosePrinter (PrinterHandle)
End If
End Function
Public Sub PrintTest()
' Print two test pages to confirm the page size.
Printer.Print "Top of Page 1."
Printer.NewPage
' Spacing between lines should reflect the chosen page height. But this doesn't work
' with the HP DesignJet 1050c
Printer.Print "Top of Page 2."
Printer.EndDoc
MsgBox "Check Printer " & Printer.DeviceName, vbInformation, "Done!"
End Sub
Finding Page Size
I build a simple browser using webbrowser control.
I need to determine the page size of the loaded document in terms of bytes.
Thanks
Page Size Of Datareport
I am trying to find any solution for sizing Datareport using 'Search the forums: '. but I can not find any solution. How can I configure Page size of Datareport.
Thanks
Set Report Page Size
I want to display my data report from a VB form using report control. The result is the report page size is set to 37% by default and I have to enlarge it to be able to read it. Can somebody tell me how to change the default setting to, like 75%?
Change Page Size?
How do I change the page size of a data report? I need 8.5"x14", but I can't figure out how to make it this size.
Thanks,
Greg
DataReport Page Size
Hi,
I have this DataReport page that only size itself to 8.5 x 11 paper size.
Is there a way that it could size or be able to print to a 8.5 x 14 paper size without altering the
section1 in which this section if more records are added actually created another page for printing
(oh yea, I'm still stack-up on that short bond paper. Where's that long bond?).
Page Size Error
I have an error appearing in my application when i try to connect to the
server
the error reads as follows
"S1000: [Microsoft][ODBC Sql Server Driver][Sql Server] Memory request for
17434 Bytes exceeds the size of single page of 2044 Bytes"
Can anyone help me..solve this
Thanx in advance
Regards,
Gijesh
Determine The Size Of A Web Page
Can anyone help me with this? I need to know the real size of a webpage not the size of the html code but the page with pictures and othr stuff. I don't know if there is a simple way to do it in VB. I only need to obtain the number of bytes to export to an Excel worksheet.
Changing Excel Page Size Through A VB App
Hi
I'm using Visual Basic to automate changing the page size field of an excel file.
We periodically need to change the page size of many excel files from A4 to letter etc...
So far its working ok on windows, but the excel files that I need to change needs to be used on Mac as well. The problem is, in Mac Excel 98 there is no page size field because this information is stored in 'Options'. So the page size value remains the same on MAC.
I guess it has to do with postscript printer settings saved in the excel file itself?
But how do you change these settings for Mac?
Is there any way to change the page setup value for Mac through my code on VB?
Example code:
Private Sub cmdProcess_Click()
Dim ExcelApp As New Excel.Application
Dim ExcelWB As Excel.Workbook
Dim ExcelWS As Excel.Worksheet
Dim savePathStr As String ' save path to overwrite
savePathStr = txtFile.Text
Set ExcelWB = ExcelApp.Workbooks.Open(savePathStr)
Set ExcelWS = ExcelWB.Worksheets(1)
ExcelWS.PageSetup.PaperSize = xlPaperA4
ExcelWB.SaveAs savePathStr, xlNormal
ExcelWB.Close
ExcelApp.Quit
End Sub
Any suggestions appreciated...
thanks!
WebBrowser Control, Page Size To Fit
I want to use a WebBrowser control to display a website in a program. The Website is a standard 800X600 which requires making both the form and control very large. I would like to size the control much smaller but want the full page to show in the control without the use of scrollbars.
I have seen some posts from years ago of someone looking to do this same thing but never found a resolution to this problem.
Any ideas?
Thanks
Can I Resize Webbrowser To Size Of Web Page?
I doubt this can be done but it never hurts to ask!
Is there any way the webbrowser control can be resized to the web page so there are no scroll bars?
What i am trying to do it resize the webbrowser control to the size of the web page and the webbrowser control is in a picturebox control. Then I am going to use some code I found that captures and saved the picturebox and the contents to an image file. This way I have the whole web page saved as an image.
Any suggestions?
Thanks!
How To Disable Page File Size?
Guys,
i got a few question here
1. how to disable the page file size in Windows 2000
2. how to configure the pagefile size setting through vb6?? can that be done?
Changing Printer Page Size
I am writing a label program. My problem is, when I use CommonDialog1.ShowPrinter
and enter the number of labels, it prints 1 label per page.
I need to make the page height 2 5/8 in. I think.
I put the code for 1 label in a for next loop. I still get 1 label, 1 page.
This is going to be used with a dot impact printer but I am writing & testing on a ink jet, so I figure I should be able to get at least 3 per page.
Thanks
Full Page Size In Datareport
How can I put a image in a datareport that uses the whole page?
If I use a RptImage-control and place that in the detail section, I always get a huge margin on the left, a smaller one on the right!
Is it possible to remove this margins?
Or to print the picture as big as possible?
Full Page Size In Datareport
How can I put a image in a datareport that uses the whole page?
If I use a RptImage-control and place that in the detail section, I always get a huge margin on the left, a smaller one on the right!
Is it possible to remove this margins?
Or to print the picture as big as possible?
Datareport On Legal Size Page
Hello Group,
Please let me know how Legal size page width is set in vb6 datareport, if
possible please provide me more details how to use larger report than A4
size, how to use in Datareport, I can handle A4 size report but when trying
report on Legal there is width error is generated.
Thanks / altaf
Printing A Full Size Page
I an a friend are writing a POS program for the very first time and have got stuck on some snags. The main one is printing a full A4 page with customers and order details on (like a reciept) and various other variables (date etc). But for some reason even with the form maximized when we print the form it only prints on half of the page. Also I want it to continue onto another page if the list of items bought doesnt all fit on... but any other page needs to have some header and footer info on so if the pages are seperated we can check with what order the belong to. Please see below for an example.
A4 Page should look like this when printed.
------------------------------------------------------------------------------------
Reciept For Order No xxx-xxx
Date
Time
Assistant
Customer Address
blah
blah
blah
Post Code
----------------------------------------------------------------------------------
Items Purchased
Item 1
Item 2
Item 3
Item 4
Item 5
etc
etc
---------------------------------------------------------------------------------
Total No Of Items
Thank you For Shopping Here
Some Terms and Conditions etc.
--------------------------------------------------------------------------------
This works fine using a form but when the list items gets toa certain size they get hidden. I would like it to print off the items on continuation pages while keeping the header and footer the same. I have thought about Data Report but it seems very complex and not all the data is in a database its simply just printed from whats entered etc.
Can someone help me?
CR Page Size & Network Printing
how to set the paper size. I need to take a report in thermal Printer (which is very small one).
2nd Question: I have around 3 reports (may vary dynamically) and each report will go to separate printer which is connected in network. How can i set the printer during run time??
Data Report Page Size
May I know how to change the page size of a data report? I would like to make a report of A3 size. Thanks
Clive
Printer Page Size Changing
i use datareport for printing
my printer default page size is letter but i want to change this defult setting to A4 size how can i do this
i use this code before printing data report
printer.printsize = A4
but it didnot work accordingly
Thanks
Resize Web Page To Browser Size
Hi
i have a webbrowser1 control on my form. i use this to .navigate to an url.
my problem is that i want the resulting web page to fit to the size of the webbrowser1 control (i.e. shrink to fit)
from this, i may want the form resizable, and the browser dimensions to change with it, but the web page inside of this to remain the size of the browser...
i cannot find a control, method, property, etc, to do this - any help would be appreciated.
thanks,
jingo_man
Advice Needed! Richtextbox Page Size
Hi,
I have a form that is using richtextbox to enter/edit Byzantine Notation. The Richtextbox is 8.5"X11". The scroll bars are enabled for both V and H. Now, the problem I can't see the text on the bottom of the page or either scroll up/down. Is there a way to use the mdi form to view the Richtextbox. For example, Word has nice view and you control the textbox from the mainwindow. I have attached the program and you can see the problem/issue.
Urgent...Data Report Page Size
Hello,
Data Report in VB 6.0 by default is set to print on an A4 size paper. I have a generated a larger report ( A3 size). But when I run the report it gives me an error that report width exceeds page size.
How to increase the size of the data report so that i can generate and print the required report.
Thanx.
If u have the answer plz reply asap.
Kaustubh
India
Crystal SubReport Page Size Problem
Hi,
i have placed 3 subreports in my main report. when any of these reports exceed than the size of page i found an error msg "Page size was not large enough to format the content of an object in the report". i want that my subreports contiously move to next pages. My second question is that is it possible to show my sub report on next page same as we can show every group on its on page.
thanks
Resize Webbrowser Control To Size Of Web Page?
Is there any way the webbrowser control can be resized to the web page so there are no scroll bars?
What I am trying to do it resize the webbrowser control to the size of the web page and the webbrowser control is in a picturebox control. Then I am going to use some code I found that captures and saved the picturebox and the contents to an image file. This way I have the whole web page saved as an image.
Any suggestions?
Thanks!
Trouble Setting Printer Page Size
I'm beating my head against the wall here - please help!
I need to be able to set the page (paper) size of a printer whether it's installed locally or as a network printer.
Most importantly, I need to be able to set the page size OUTSIDE OF MY VB APP. I've seen code for setting the default printer, which is a system setting.
Well, I need to set the page size of *any* installed printer, so that it stays after my vb app closes.
I've got some code (I can't remember where I got it) which is supposed to do this, but it doesn't work.
Can anyone either:
1) Show me how to fix this code OR
2) Provide code that works ! (Win2K/Winnt 4 sp6/XP/Server2K)
I can't use the Printer Dialog either because there is no user interface in my app....
Here's what I have, which does nothing on my win2k pc:
Code:
'On a form
Private Sub Form_Load()
Dim mypapersize As Integer
Call SetPapersize(DMDUP_SIMPLEX, vbPRPSLegal, Me)
End Sub
'In a MODULE:
'Constants used in the DevMode structure
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
'Constants for NT security
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const PRINTER_ACCESS_ADMINISTER = &H4
Private Const PRINTER_ACCESS_USE = &H8
Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)
'Constants used to make changes to the values contained in the DevMode
Private Const DM_MODIFY = 8
Private Const DM_IN_BUFFER = DM_MODIFY
Private Const DM_COPY = 2
Private Const DM_OUT_BUFFER = DM_COPY
Private Const DM_DUPLEX = &H1000&
Public Const DMDUP_SIMPLEX = 1
Private Const DMDUP_VERTICAL = 2
Private Const DMDUP_HORIZONTAL = 3
Private Const DM_ORIENTATION = &H1&
Private PageDirection As Integer
Private mypapersize As Integer
'The DevMode structure contains printing parameters.
'Note that this only represents the PUBLIC portion of the DevMode.
' The full DevMode also contains a variable length PRIVATE section
' which varies in length and content between printer drivers.
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmLogPixels As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
dmICMMethod As Long ' // Windows 95 only
dmICMIntent As Long ' // Windows 95 only
dmMediaType As Long ' // Windows 95 only
dmDitherType As Long ' // Windows 95 only
dmReserved1 As Long ' // Windows 95 only
dmReserved2 As Long ' // Windows 95 only
End Type
Private Type PRINTER_DEFAULTS
'Note:
' The definition of Printer_Defaults in the VB5 API viewer is incorrect.
' Below, pDevMode has been corrected to LONG.
pDatatype As String
pDevMode As Long
DesiredAccess As Long
End Type
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
Private Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal Command As Long) As Long
Private Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
'The following is an unusual declaration of DocumentProperties:
' pDevModeOutput and pDevModeInput are usually declared ByRef. They are declared
' ByVal in this program because we're using a Printer_Info_2 structure.
' The pi2 structure contains a variable of type LONG which contains the address
' of the DevMode structure (this is called a pointer). This LONG variable must
' be passed ByVal.
' Normally this function is called with a BYTE ARRAY which contains the DevMode
' structure and the Byte Array is passed ByRef.
Private Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hwnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, ByVal pDevModeOutput As Any, ByVal pDevModeInput As Any, ByVal fMode As Long) As Long
Public Sub SetPapersize(NewSetting As Long, chng As Integer, ByVal frm As Form)
Dim PrinterHandle As Long
Dim PrinterName As String
Dim pd As PRINTER_DEFAULTS
Dim MyDevMode As DEVMODE
Dim Result As Long
Dim Needed As Long
Dim pFullDevMode As Long
Dim pi2_buffer() As Long 'This is a block of memory for the Printer_Info_2 structure
'If you need to use the Printer_Info_2 User Defined Type, the
' definition of Printer_Info_2 in the API viewer is incorrect.
' pDevMode and pSecurityDescriptor should be defined As Long.
PrinterName = Printer.DeviceName
If PrinterName = "" Then
Exit Sub
End If
pd.pDatatype = vbNullString
pd.pDevMode = 0&
'Printer_Access_All is required for NT security
pd.DesiredAccess = PRINTER_ALL_ACCESS
Result = OpenPrinter(PrinterName, PrinterHandle, pd)
'The first call to GetPrinter gets the size, in bytes, of the buffer needed.
'This value is divided by 4 since each element of pi2_buffer is a long.
Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed)
ReDim pi2_buffer((Needed 4))
Result = GetPrinter(PrinterHandle, 2, pi2_buffer(0), Needed, Needed)
'The seventh element of pi2_buffer is a Pointer to a block of memory
' which contains the full DevMode (including the PRIVATE portion).
pFullDevMode = pi2_buffer(7)
'Copy the Public portion of FullDevMode into our DevMode structure
Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode))
'Make desired changes
MyDevMode.dmDuplex = NewSetting
MyDevMode.dmFields = DM_DUPLEX Or DM_ORIENTATION
MyDevMode.dmPaperSize = chng
'Copy our DevMode structure back into FullDevMode
Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode))
'Copy our changes to "the PUBLIC portion of the DevMode" into "the PRIVATE portion of the DevMode"
Result = DocumentProperties(frm.hwnd, PrinterHandle, PrinterName, ByVal pFullDevMode, ByVal pFullDevMode, DM_IN_BUFFER Or DM_OUT_BUFFER)
'Update the printer's default properties (to verify, go to the Printer folder
' and check the properties for the printer)
Result = SetPrinter(PrinterHandle, 2, pi2_buffer(0), 0& )
'******* NOTHING CHANGES AFTER THE ABOVE LINE OF CODE IS EXECUTED
Call ClosePrinter(PrinterHandle)
'Note: Once "Set Printer = " is executed, anywhere in the code, after that point
' changes made with SetPrinter will ONLY affect the system-wide printer --
' -- the changes will NOT affect the VB printer object.
' Therefore, it may be necessary to reset the printer object's parameters to
' those chosen in the devmode.
Dim p As Printer
For Each p In Printers
If p.DeviceName = PrinterName Then
Set Printer = p
Exit For
End If
Next p
Printer.Duplex = MyDevMode.dmDuplex
End Sub
THANKS!
|