Print closed Excel Workbook from Access

rogerm

Board Regular
Joined
May 12, 2002
Messages
53
Could anyone help me with some Vba to print a closed Excel workbook from access (or open it, print it then close it again)
Thank you.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Sure! Try something like this. You will need to set a reference (Tools-References from the VBE) to Microsoft Excel X.x Object Library.

<pre><font color='#000000'>
<font color='#000080'>Option</font> <font color='#000080'>Compare</font> Database
<font color='#000080'>Option</font> <font color='#000080'>Explicit</font>

<font color='#000080'>Sub</font> PrintXL()
<font color='#000080'>Dim</font> objXL <font color='#000080'>As</font> Excel.Application
<font color='#000080'>Dim</font> wbk <font color='#000080'>As</font> Excel.Workbook

<font color='#000080'>Set</font> objXL = New Excel.Application
<font color='#008000'>' open the workbook</font>
<font color='#000080'>Set</font> wbk = objXL.Workbooks.Open("D:Dataslamson.xls")
<font color='#008000'>' print the workbook</font>
wbk.PrintOut
<font color='#008000'>' close workbook w/o saving changes</font>
wbk.Close False

<font color='#000080'>Set</font> wbk = Nothing

objXL.Quit

<font color='#000080'>Set</font> objXL = Nothing

<font color='#000080'>End</font> <font color='#000080'>Sub</font>

</font></pre>
.
You can control how many copies/what pages print by looking up the PrintOut method in help.

Hope this helps,

Russell
 
Upvote 0
Thats brilliant - thanks for the prompt reply I've been trying to figure out how to do it for about an hour or more and couldn't quite make it work.
 
Upvote 0

Forum statistics

Threads
1,221,498
Messages
6,160,160
Members
451,626
Latest member
dcobe

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