Hi,<br>I have an Access 2000 application, and when I send out the runtime version, the margins and orientation for my reports gets reset. I researched it on the net, and modified a function from someone elses modification of code in Microst Access 95 Developers Handbook. <br>It works great to change the orientation from Portrait to Landscape, but when I use it to change the margins, it does not work. When I go to a report, it says printer not found, and resets the margins to one inch.<br>Any insight into my problem?<br>Thanks,<br>Rik<br><br>Code:Option Compare Database<br><br>Const glrcDeviceNameLen = 32<br>Const glrcFormNameLen = 32<br> <br>' This is the number of bytes in the fixed portion of<br>' the DEVMODE structure. We've just broken the<br>' two sizes apart in case the fixed portion of<br>' the structure changes.<br>Const glrcDevModeSize = 148<br>' This is an arbitrary value. Based on experience,<br>' it ought to be large enough.<br>Const glrcExtraSize = 1024<br>Const glrcDevModeMaxSize = glrcDevModeSize + glrcExtraSize<br> <br>' Structure for prtDevMode<br>Type glr_tagDevMode<br> strDeviceName(1 To glrcDeviceNameLen) As Byte<br> intSpecVersion As Integer<br> intDriverVersion As Integer<br> intSize As Integer<br> intDriverExtra As Integer<br> lngFields As Long<br> intOrientation As Integer<br> intPaperSize As Integer<br> intPaperLength As Integer<br> intPaperWidth As Integer<br> intScale As Integer<br> intCopies As Integer<br> intDefaultSource As Integer<br> intPrintQuality As Integer<br> intColor As Integer<br> intDuplex As Integer<br> intYResolution As Integer<br> intTTOption As Integer<br> intCollate As Integer<br> strFormName(1 To glrcFormNameLen) As Byte<br> intLogPixels As Integer<br> lngBitsPerPixel As Long<br> lngPelsWidth As Long<br> lngPelsHeight As Long<br> lngDisplayFlags As Long<br> lngDisplayFrequency As Long<br> lngICMMethod As Long<br> lngICMIntent As Long<br> lngMediaType As Long<br> lngDitherType As Long<br> lngICCManufacturer As Long<br> lngICCModel As Long<br> bytDriverExtra(1 To glrcExtraSize) As Byte<br>End Type<br> <br>' Structure for prtDevNames<br>Type glr_tagDevNames<br> intDriverPos As Integer<br> intDevicePos As Integer<br> intOutputPos As Integer<br> intDefault As Integer<br>End Type<br> <br>' Structure for prtMip<br>Type glr_tagMarginInfo<br> lngLeft As Long<br> lngTop As Long<br> lngRight As Long<br> lngBottom As Long<br> lngDataOnly As Long<br> lngWidth As Long<br> lngHeight As Long<br> lngDefaultSize As Long<br> lngItemsAcross As Long<br> lngColumnSpacing As Long<br> lngRowSpacing As Long<br> lngItemLayout As Long<br> lngFastPrinting As Long<br> lngDataSheet As Long<br>End Type<br> <br>' Temp structure for prtDevMode info.<br>Type glr_tagDevModeStr<br>strDevMode As String * glrcDevModeMaxSize<br>End Type<br> <br>Public Function SetReportFormat(strRptName As String) As Byte<br>On Error GoTo Err_SetReportFormat<br> <br> Dim DM As glr_tagDevMode<br> Dim PS As glr_tagMarginInfo<br> Dim DMStr As glr_tagDevModeStr<br> Dim PSStr As glr_tagDevModeStr<br> 'Open report in design view<br> Application.Echo False<br> <br> DoCmd.OpenReport strRptName, acViewDesign<br> <br> 'Get the DevMode settings<br> DMStr.strDevMode = Reports(strRptName).PrtDevMode<br> <br> 'Put the DevMode settings in User-Defined Type structure<br> LSet DM = DMStr<br> <br> 'Change the Paper Orientation to Landscape<br> <br> DM.intOrientation = 2<br> 'Assign changed setting back to User-Defined Type string<br> LSet DMStr = DM<br> <br> 'Assign changed setting string to the reports DevMode<br> Reports(strRptName).PrtDevMode = DMStr.strDevMode<br> DoCmd.Save acReport, strRptName<br><br> 'Get the DevMode settings<br> PSStr.strDevMode = Reports(strRptName).PrtDevMode<br> <br> 'Put the DevMode settings in User-Defined Type structure<br> LSet PS = PSStr<br> <br> 'Change the Margins to minimum (I used msgbox ps.lngTop, etc., on a correctly formatted report to get these values)<br> <br> PS.lngBottom = 1919251297<br> PS.lngTop = 1919251297<br> PS.lngLeft = 1277186120<br> PS.lngRight = 1277186120<br><br> 'Assign changed setting back to User-Defined Type string<br> LSet PSStr = PS<br> <br> 'Assign changed setting string to the reports DevMode<br> Reports(strRptName).PrtDevMode = PSStr.strDevMode<br> <br> 'Save the changes and close the report<br> DoCmd.Save acReport, strRptName<br> DoCmd.Close acReport, strRptName<br> SetReportFormat = True<br> <br> Application.Echo True<br> <br>Exit_SetReportFormat:<br> Exit Function<br>Err_SetReportFormat:<br> SetReportFormat = False<br> MsgBox Err.description<br> Resume Exit_SetReportFormat<br>End Function