Solved

How to print Excel worksheet from Access 2007

Posted on 2014-02-03
3
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 25

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sIMULTANEOUS USAGE ON NETWORK-ACCESS 2010-2013 7 77
Calculation in a Report 13 43
Combo box with two columns question 7 40
ACCESS / VBA - Count of Rows in Table 4 47
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

738 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