T
Tony Epton
Win XP, Access 2003, Adobe 6.0 Professional
I am attempting to switch a report between the default printer and an
Adobe driver. (switching at user discretion via a tick box call ChkPDF
- logic not shown in code below)
ISSUE 1
-------------
I have done some reading about prtDevMode and this is the code I have
tried so far:
Private Type str_DEVMODE
RGB As String * 94
End Type
Private Type type_DEVMODE
strDeviceName As String * 32
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 * 32
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Sub PatchReportPrinter()
Dim rpt As Report
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
DoCmd.OpenReport "rptGraph", acViewDesign
Set rpt = Reports![rptGraph]
strDevModeExtra = rpt.PrtDevMode
' Gets current DEVMODE structure.
DevString.RGB = strDevModeExtra
LSet DM = DevString
MsgBox DM.strDeviceName
end sub
If I leave the report design set to the default printer and run this
code, the message box line above gives a blank response (could be 32
spaces - have not checked yet).
When I hand code the report design to go to a specific printer "Adobe"
and then run the code then the message box line above yields "????F"
which is not what I am expecting.
I must be doing something wrong already - so don't want to go any
further with the code where I alter the DeviceName and stuff it back
in to rpt.DevMode
Any suggestion please - much appreciated.
ISSUE 2
-------------
If I circumvent this code and just hard code the report to go to adobe
- then adobe generates a file : My Documents\rptGraph.pdf
I would like to grab this file and copy it to another location (and
another name)
Here is my code so far
sub CopyPDFToNamedFile(strOutputFileName as string)
DoCmd.OpenReport "rptGraph", acViewNormal
'Arbitary delay because we don't know when Adobe has finished
For i = 1 To 1000
DoEvents
Next i
strUserName = "Administrator"
strMyDocuments = "C:\Documents and Settings\" & strUserName & "\My
Documents"
FileCopy strMyDocuments & "\rptGraph.pdf", strOutputFileName
end sub
As you can see - I have hardcoded the user name.
Can anyone tell me how to pick this name up using some function.
(NOT the access login name)
Many thanks in advance
Tony Epton
I am attempting to switch a report between the default printer and an
Adobe driver. (switching at user discretion via a tick box call ChkPDF
- logic not shown in code below)
ISSUE 1
-------------
I have done some reading about prtDevMode and this is the code I have
tried so far:
Private Type str_DEVMODE
RGB As String * 94
End Type
Private Type type_DEVMODE
strDeviceName As String * 32
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 * 32
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Sub PatchReportPrinter()
Dim rpt As Report
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
DoCmd.OpenReport "rptGraph", acViewDesign
Set rpt = Reports![rptGraph]
strDevModeExtra = rpt.PrtDevMode
' Gets current DEVMODE structure.
DevString.RGB = strDevModeExtra
LSet DM = DevString
MsgBox DM.strDeviceName
end sub
If I leave the report design set to the default printer and run this
code, the message box line above gives a blank response (could be 32
spaces - have not checked yet).
When I hand code the report design to go to a specific printer "Adobe"
and then run the code then the message box line above yields "????F"
which is not what I am expecting.
I must be doing something wrong already - so don't want to go any
further with the code where I alter the DeviceName and stuff it back
in to rpt.DevMode
Any suggestion please - much appreciated.
ISSUE 2
-------------
If I circumvent this code and just hard code the report to go to adobe
- then adobe generates a file : My Documents\rptGraph.pdf
I would like to grab this file and copy it to another location (and
another name)
Here is my code so far
sub CopyPDFToNamedFile(strOutputFileName as string)
DoCmd.OpenReport "rptGraph", acViewNormal
'Arbitary delay because we don't know when Adobe has finished
For i = 1 To 1000
DoEvents
Next i
strUserName = "Administrator"
strMyDocuments = "C:\Documents and Settings\" & strUserName & "\My
Documents"
FileCopy strMyDocuments & "\rptGraph.pdf", strOutputFileName
end sub
As you can see - I have hardcoded the user name.
Can anyone tell me how to pick this name up using some function.
(NOT the access login name)
Many thanks in advance
Tony Epton