Solved

How to print Excel worksheet from Access 2007

Posted on 2014-02-03
3
425 Views
Last Modified: 2014-02-04
Similar questions here at the exchange offered (aging) solutions which I couldn't make work, so I thought I'd get the latest.  I simply need to print a spreadsheet; I don't need to link it to the database, and it has never been linked to the db.
0
Comment
Question by:David_W_R
3 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 400 total points
ID: 39830896
You can use a bit of VBA code for that:
Dim xlTmp As Object
Set xlTmp = CreateObject("Excel.Application")
xlTmp.Visible = False
Dim xlWbk As Object
Set xlWbk = xlTmp.Workbooks.Open("C:\Excel1.xls")
xlWbk.PrintOut
xlWbk.Close SaveChanges:=False
xlTmp.Quit
Set xlTmp = Nothing

Open in new window

0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 100 total points
ID: 39830927
try this codes


Dim xlobj As Object, xlFile As String
xlFile = CurrentProject.Path & "\TestFile.xlsx"
Set xlobj = CreateObject("excel.application")
     xlobj.Workbooks.Open xlFile
     xlobj.Worksheets("sheet2").Select
     xlobj.Worksheets("sheet2").PrintOut
     xlobj.Quit
0
 

Author Closing Comment

by:David_W_R
ID: 39833603
chaau, your method worked flawlessly; just had to add add "ActiveSheet" to the command.
Rey Obrero, your method appears similar, but I didn't have time to check it.  Either way, it has a couple of items that will help me understand more about this subject.  Thank you both for the timely response.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now