J
JimP
Is there a way to loop through the Reports collection of an mdb and identify
the name of the printer saved with each report?
the name of the printer saved with each report?
Graham Mandeno said:Hi Jim
This ought to do the trick:
Sub ListReportPrinters()
Dim rpt As AccessObject
For Each rpt In CurrentProject.AllReports
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
With Reports(rpt.Name)
Debug.Print .Name; Tab(30); .Printer.DeviceName; _
IIf(.UseDefaultPrinter, " <default>", "")
End With
DoCmd.Close acReport, rpt.Name
Next
End Sub
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
JimP said:Is there a way to loop through the Reports collection of an mdb and
identify the name of the printer saved with each report?
Graham Mandeno said:Hi Jim
This ought to do the trick:
Sub ListReportPrinters()
Dim rpt As AccessObject
For Each rpt In CurrentProject.AllReports
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
With Reports(rpt.Name)
Debug.Print .Name; Tab(30); .Printer.DeviceName; _
IIf(.UseDefaultPrinter, " <default>", "")
End With
DoCmd.Close acReport, rpt.Name
Next
End Sub
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
JimP said:Is there a way to loop through the Reports collection of an mdb and
identify the name of the printer saved with each report?
JimP said:I've run into a snag. I get an error message when the report opens and the
printer is not available. Can I disable the error message?
"This document was previously formatted for the printer ..., but that
printer isn't available. Do you want to use the default printer ...?
Graham Mandeno said:Hi Jim
This ought to do the trick:
Sub ListReportPrinters()
Dim rpt As AccessObject
For Each rpt In CurrentProject.AllReports
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
With Reports(rpt.Name)
Debug.Print .Name; Tab(30); .Printer.DeviceName; _
IIf(.UseDefaultPrinter, " <default>", "")
End With
DoCmd.Close acReport, rpt.Name
Next
End Sub
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
JimP said:Is there a way to loop through the Reports collection of an mdb and
identify the name of the printer saved with each report?
Jack Leach said:Get the error number and put an error trap in the loop for that number.
Set
the debug.print to something like "no printer" if err.number = whatever
this
error is.
--
Jack Leach
www.tristatemachine.com
"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
JimP said:I've run into a snag. I get an error message when the report opens and
the
printer is not available. Can I disable the error message?
"This document was previously formatted for the printer ..., but that
printer isn't available. Do you want to use the default printer ...?
Graham Mandeno said:Hi Jim
This ought to do the trick:
Sub ListReportPrinters()
Dim rpt As AccessObject
For Each rpt In CurrentProject.AllReports
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
With Reports(rpt.Name)
Debug.Print .Name; Tab(30); .Printer.DeviceName; _
IIf(.UseDefaultPrinter, " <default>", "")
End With
DoCmd.Close acReport, rpt.Name
Next
End Sub
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
Is there a way to loop through the Reports collection of an mdb and
identify the name of the printer saved with each report?
JimP said:I have an error handler in the routine. This "message window" does not trip
an error. The message window appears upon opening up the report, e.g.
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
..not sure what I can do - there's too many reports to consider opening
each one manually.
JimP said:I have an error handler in the routine. This "message window" does not trip
an error. The message window appears upon opening up the report, e.g.
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
...not sure what I can do - there's too many reports to consider opening each
one manually.
Jack Leach said:Get the error number and put an error trap in the loop for that number.
Set
the debug.print to something like "no printer" if err.number = whatever
this
error is.
--
Jack Leach
www.tristatemachine.com
"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
JimP said:I've run into a snag. I get an error message when the report opens and
the
printer is not available. Can I disable the error message?
"This document was previously formatted for the printer ..., but that
printer isn't available. Do you want to use the default printer ...?
Hi Jim
This ought to do the trick:
Sub ListReportPrinters()
Dim rpt As AccessObject
For Each rpt In CurrentProject.AllReports
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
With Reports(rpt.Name)
Debug.Print .Name; Tab(30); .Printer.DeviceName; _
IIf(.UseDefaultPrinter, " <default>", "")
End With
DoCmd.Close acReport, rpt.Name
Next
End Sub
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
Is there a way to loop through the Reports collection of an mdb and
identify the name of the printer saved with each report?
JimP said:I have an error handler in the routine. This "message window" does not trip
an error. The message window appears upon opening up the report, e.g.
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
..not sure what I can do - there's too many reports to consider opening
each one manually.
Dirk Goldgar said:Another possibility, though a bit complicated and clunky, is to save the
report design as a text file:
Application.SaveAsText acReport, rpt.Name, _
CurrentProject.Path & "\" & rpt.Name & ".txt"
... and then use standard VB I/O statements to read and parse the text file.
If you open the text file in NotePad, you can see the PrtDevMode and
PrtDevNames structures, and can probably work out how to parse and interpret
them.
Graham Mandeno said:Hi Jim
[I normally wouldn't do this, but I'm cc-ing your email just in case]
I hope I'm not too late, but DO NOT USE SetWarnings False.
If you do, then the "do something" option will be used for anything you
would otherwise get a prompt for.
So, instead of asking you, the report WILL be modified to use the default
printer, then, because the report's design has changed, the changes will
be saved without asking when you close the report. Any record that the
report once used a non-default but unavailable printer will be lost.
Just for safety, I suggest you add acSaveNo to the DoCmd.Close.
I believe the only practical way to do this is to use Dirk's suggestion
and dump the report design into a text file with SaveAsText.
The problem is that the printer info is hard to decode. You get something
like this:
PrtDevNames = Begin
0x080012002b00000077696e73706f6f6c002d5c5c43524f4e4f535c43616e6f6e
,
0x204c42502d3137363000284c5054313a00204c5054313a0036302028322d7570
,
0x2900
End
The printer name (and whether or not it's the default printer) are buried
in the hex strings!
If you're really serious about doing this, I'm happy to help you knock up
some code. Let me know. But please reply to the newsgroup, not the
email.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
JimP said:Thanks to all. I'll give the SetWarnings a try. Also, I Googled the error
below, and there may be some other issues.
"This document was previously formatted for the printer ..., but that
printer isn't available. Do you want to use the default printer ...?
Tony Toews said:Even I tread carefully and softly when it comes to PrtDevMode.
Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/
Graham Mandeno said:Hi Jim
[I normally wouldn't do this, but I'm cc-ing your email just in case]
I hope I'm not too late, but DO NOT USE SetWarnings False.
If you do, then the "do something" option will be used for anything you
would otherwise get a prompt for.
So, instead of asking you, the report WILL be modified to use the default
printer, then, because the report's design has changed, the changes will
be saved without asking when you close the report. Any record that the
report once used a non-default but unavailable printer will be lost.
Just for safety, I suggest you add acSaveNo to the DoCmd.Close.
I believe the only practical way to do this is to use Dirk's suggestion
and dump the report design into a text file with SaveAsText.
The problem is that the printer info is hard to decode. You get something
like this:
PrtDevNames = Begin
0x080012002b00000077696e73706f6f6c002d5c5c43524f4e4f535c43616e6f6e
,
0x204c42502d3137363000284c5054313a00204c5054313a0036302028322d7570
,
0x2900
End
The printer name (and whether or not it's the default printer) are buried
in the hex strings!
If you're really serious about doing this, I'm happy to help you knock up
some code. Let me know. But please reply to the newsgroup, not the
email.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
JimP said:Thanks to all. I'll give the SetWarnings a try. Also, I Googled the error
below, and there may be some other issues.
"This document was previously formatted for the printer ..., but that
printer isn't available. Do you want to use the default printer ...?
JimP said:Thanks. But, if I wanted to save each report using the default printer
(and save the settings), then it sounds like this would work.
Graham Mandeno said:Hi Jim
[I normally wouldn't do this, but I'm cc-ing your email just in case]
I hope I'm not too late, but DO NOT USE SetWarnings False.
If you do, then the "do something" option will be used for anything you
would otherwise get a prompt for.
So, instead of asking you, the report WILL be modified to use the default
printer, then, because the report's design has changed, the changes will
be saved without asking when you close the report. Any record that the
report once used a non-default but unavailable printer will be lost.
Just for safety, I suggest you add acSaveNo to the DoCmd.Close.
I believe the only practical way to do this is to use Dirk's suggestion
and dump the report design into a text file with SaveAsText.
The problem is that the printer info is hard to decode. You get
something like this:
PrtDevNames = Begin
0x080012002b00000077696e73706f6f6c002d5c5c43524f4e4f535c43616e6f6e
,
0x204c42502d3137363000284c5054313a00204c5054313a0036302028322d7570
,
0x2900
End
The printer name (and whether or not it's the default printer) are buried
in the hex strings!
If you're really serious about doing this, I'm happy to help you knock up
some code. Let me know. But please reply to the newsgroup, not the
email.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
JimP said:Thanks to all. I'll give the SetWarnings a try. Also, I Googled the
error below, and there may be some other issues.
"This document was previously formatted for the printer ..., but that
printer isn't available. Do you want to use the default printer ...?
I have an error handler in the routine. This "message window" does not
trip an error. The message window appears upon opening up the report,
e.g.
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
..not sure what I can do - there's too many reports to consider
opening each one manually.
Another possibility, though a bit complicated and clunky, is to save
the report design as a text file:
Application.SaveAsText acReport, rpt.Name, _
CurrentProject.Path & "\" & rpt.Name & ".txt"
... and then use standard VB I/O statements to read and parse the text
file. If you open the text file in NotePad, you can see the PrtDevMode
and PrtDevNames structures, and can probably work out how to parse and
interpret them.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)