Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Export Access Report to Excel using VB

Posted on 2006-07-17
5
Medium Priority
?
404 Views
Last Modified: 2013-12-25
Hi,

Just wondering could you solve a little problem for me.
I am having trouble exporting data from an Access Report to an excel file using VB and hitting a brick wall. Any help would be much apprecicated.

Thanks in advance.
0
Comment
Question by:cstephen100
[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
  • 2
5 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 17123419
>I am having trouble exporting data from an Access Report to an excel file using VB
Just so you know, exporting an Access Report anywhere usually means all of the cosmetic formatting gets messed up.
A better idea would be to export the report's record source (table or query) into Excel, where all of the cosmetic formatting is already in place.

Dim oAccess As Access.Application
Set oAccess = CreateObject("Access.Application")
 oAccess.OpenAccessProject "drive"\your_database.mdb"
oAccess.DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "Table Name", "File Name.xls"
0
 
LVL 66

Accepted Solution

by:
Jim Horn earned 600 total points
ID: 17127633
(slight corrections)
oAccess.OpenAccessProject "c:\your_database.mdb"   'The full drive, path, and file name goes here

Also Substitute acSpreadsheetTypeExcel97 with whatever version you are running... (97-Excel 97, 8=2000, 9-XP, 10-2003)
0
 
LVL 11

Assisted Solution

by:pootle_flump
pootle_flump earned 400 total points
ID: 17128559
Jim is spot on. Reports tend to export pretty terribly, especially to excel and especially if you have even the simplest groupings set up. However the code to do so would be:

oAccess.DoCmd.OpenReport "MyReportName", acViewPreview
oAccess.DoCmd.RunCommand acCmdOutputToRTF

HTH
0
 
LVL 11

Expert Comment

by:pootle_flump
ID: 17128603
Doh - I posted the word export.

Apols it should be acCmdOutputToExcel
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 17143998
Hi cstephen100

Let us know if you need any more help or advice.

Thanks.
-Jim
0

Featured Post

Independent Software Vendors: 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

604 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