Reports keep switching to portrait

unc2plo

Board Regular
Joined
Mar 18, 2002
Messages
148
I have a ton of reports that are meant to be landscape, but about half the time they pop up in portrait.

Is there some setting taht can lock the setting and keep it?

Has anyone else ever had this problem?

Thanks,
David
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I think this is a known bug with a patch out on the MSN Support site.
What I did was to borrow some VBA that manually set the print properties each time I opened the report to ensure correct orientation.

This is not 100% the original, and I really wish I could remember where I got it from to credit the source properly. Minor changes as this is the actual code I'm using within A2K. As this was awhile ago, and I'm learning new stuff every day, some of it may even be not as efficient as it could be - as I haven't touched it in months since it already worked reliably (100%).

Mike

Type str_DEVMODE
RGB As String * 94
End Type

Type type_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer
intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
strFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type

Public Function ConvertToLandscape(ByVal strName As Variant, myOrient As Variant)
Dim rpt As Report
Dim strDevModeExtra As String
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE

'strName = "repTimeDelayedTest"
DoCmd.OpenReport strName, acDesign 'Opens report in Design view.


Set rpt = Reports(strName)

If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.lngFields = DM.lngFields Or DM.intOrientation 'Initialize fields.
DM.intOrientation = myOrient 'Landscape
LSet DevString = DM 'Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
DoCmd.Save acReport, strName
DoCmd.Close acReport, strName
End If

End Function



Public Function OpenAssignReport(ByVal repName As Variant, ByVal myOrient As Variant, _
Optional bolPrintOnly As Boolean)

Dim viewPref As VbMsgBoxResult

If Not bolPrintOnly Then
viewPref = MsgBox("Select Yes if you wish to print.", vbYesNo + vbDefaultButton2, "View or Print")
End If

Call ConvertToLandscape(repName, myOrient)
If bolPrintOnly Then viewPref = 6
Select Case viewPref
Case 6 'Yes
DoCmd.OpenReport repName, acNormal, "", ""
DoCmd.Close acReport, repName
Case Else 'No
DoCmd.OpenReport repName, acPreview, "", ""
End Select

End Function
 
Upvote 0

Forum statistics

Threads
1,221,526
Messages
6,160,340
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top