'フォーム Private Sub Command1_Click() Dim PrinterName As String Dim pd As PRINTER_DEFAULTS Dim PrinterHandle As Long Dim Result As Long Dim Needed As Long Dim pi2_buffer() As Long Dim pFullDevMode As Long Dim MyDevMode As DEVMODE PrinterName = Printer.DeviceName If PrinterName = "" Then Exit Sub Me.MousePointer = 11 pd.pDatatype = vbNullString pd.pDevMode = 0& pd.DesiredAccess = PRINTER_ALL_ACCESS Result = OpenPrinter(PrinterName, PrinterHandle, pd) Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed) ReDim pi2_buffer((Needed \ 4)) Result = GetPrinter(PrinterHandle, 2, pi2_buffer(0), Needed, Needed) pFullDevMode = pi2_buffer(7) Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode)) With MyDevMode .dmOrientation = DMORIENT_PORTAIT '縦向き .dmPaperSize = 256 .dmPaperLength = 4000 .dmPaperWidth = 2500 .dmFields = DM_PAPERSIZE Or DM_PAPERWIDTH Or DM_PAPERLENGTH End With Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode)) Result = SetPrinter(PrinterHandle, 2, pi2_buffer(0), 0&) Call ClosePrinter(PrinterHandle) Me.MousePointer = 0 End Sub