Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to print Excel worksheet from Access 2007

Posted on 2014-02-03
3
Medium Priority
?
464 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 1600 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 400 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

704 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