Solved

How to print Excel worksheet from Access 2007

Posted on 2014-02-03
3
447 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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

830 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