Does anyone have experience with selecting paper size using C#? There is a great macro on Codestack (here) but it uses a VBA function "Device Capabilities" that, according to me reading, does not exist in C#.
Thanks,
Jordan
API Select Printer Paper Size - C#
-
- Posts: 26
- Joined: Wed Jul 21, 2021 3:20 pm
- x 6
- x 2
Re: API Select Printer Paper Size - C#
I know it's not a ton of help, since it's not directly in c#, but you should be able to translate it pretty easily.
The below code picks A (8.5" x 11") and B(11" x 17")
This may also help if you haven't looked at it yet.
API Help Page - PageSetup Example c#
The below code picks A (8.5" x 11") and B(11" x 17")
Code: Select all
With swModel.PageSetup
Select Case PaperSize
Case "A"
.PrinterPaperSize = 1
.ScaleToFit = True
swPSize = 1
Case "B"
.PrinterPaperSize = 17
swPSize = 17
.ScaleToFit = True
Case Else
MsgBox("Error! You must select a page size before printing!")
Exit Sub
End Select
End With
API Help Page - PageSetup Example c#
Re: API Select Printer Paper Size - C#
ThisJordan Brown wrote: ↑Thu Mar 10, 2022 7:06 am Does anyone have experience with selecting paper size using C#? There is a great macro on Codestack (here) but it uses a VBA function "Device Capabilities" that, according to me reading, does not exist in C#.
Thanks,
Jordan
Stack Overflow post may help.