Changing reports page margin in vba

  • Thread starter Thread starter Felix
  • Start date Start date
F

Felix

I need to change the left page margin of a report by means of code. I just
can't
figure out how this is done; I did not even find an attribute or method that
would allow to do so.

Any idea how to change the page margins of a report in vba code?

Many thanks, Felix
 
Adapted from Access help. Paste the following in a Standard module, save it
and run it from the debug (Immediate) window. Depending upon what you want
to do next, you may need to save and close the report:

Option Compare Database
Option Explicit

Type str_PRTMIP
strRGB As String * 28
End Type
Type type_PRTMIP
intLeftMargin As Integer
intTopMargin As Integer
intRightMargin As Integer
intBotMargin As Integer
intDataOnly As Integer
intWidth As Integer
intHeight As Integer
intDefaultSize As Integer
intColumns As Integer
intColumnSpacing As Integer
intRowSpacing As Integer
intItemLayout As Integer
intFastPrint As Integer
intDatasheet As Integer
End Type

Function SetLeftMargin(strName As String)
Dim PrtMipString As str_PRTMIP
Dim PM As type_PRTMIP
Dim rpt As Report

DoCmd.OpenReport strName, acDesign
Set rpt = Reports(strName)
PrtMipString.strRGB = rpt.PrtMip
LSet PM = PrtMipString
PM.intLeftMargin = 1 * 360 ' Set Left margin to 1/4 inch
LSet PrtMipString = PM ' Update property
rpt.PrtMip = PrtMipString.strRGB

End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Arvin Meyer said:
Adapted from Access help. Paste the following in a Standard module,
save it and run it from the debug (Immediate) window. Depending upon
what you want to do next, you may need to save and close the report:

Option Compare Database
Option Explicit

Type str_PRTMIP
strRGB As String * 28
End Type
Type type_PRTMIP
intLeftMargin As Integer
intTopMargin As Integer
intRightMargin As Integer
intBotMargin As Integer
intDataOnly As Integer
intWidth As Integer
intHeight As Integer
intDefaultSize As Integer
intColumns As Integer
intColumnSpacing As Integer
intRowSpacing As Integer
intItemLayout As Integer
intFastPrint As Integer
intDatasheet As Integer
End Type

Function SetLeftMargin(strName As String)
Dim PrtMipString As str_PRTMIP
Dim PM As type_PRTMIP
Dim rpt As Report

DoCmd.OpenReport strName, acDesign
Set rpt = Reports(strName)
PrtMipString.strRGB = rpt.PrtMip
LSet PM = PrtMipString
PM.intLeftMargin = 1 * 360 ' Set Left margin to 1/4 inch
LSet PrtMipString = PM ' Update property
rpt.PrtMip = PrtMipString.strRGB

End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Many thanks! This is what I was looking for.

Felix
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top