473,396 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Opening a Document in Excel Format in Access

I am using the following command to open a query in Excel:

DoCmd.OutputTo acOutputQuery, "qryTest", acFormatXLS, , True

The problem is that the code creates an Excel 97 file. Is there a way
using code to create an Excel 2000 or 2002 file?

Marcus
******

Nov 13 '05 #1
4 1751
Marcus,
Maybe. It's a kludge, but you could run an instance of Excel in your code
that opened the saved result of outputting the query and saved it in the
format you want.
--
Alan Webb
kn*******@SPAMhotmail.com
"It's not IT, it's IS"

"Marcus" <to*******@yahoo.ca> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I am using the following command to open a query in Excel:

DoCmd.OutputTo acOutputQuery, "qryTest", acFormatXLS, , True

The problem is that the code creates an Excel 97 file. Is there a way
using code to create an Excel 2000 or 2002 file?

Marcus
******

Nov 13 '05 #2
Would you happen to have any samples of this, or know where I could
find samples on this?

Marcus
*******

Nov 13 '05 #3
Marcus,
It's a fairly straightforward bit of coding. I am pretty sure it's been
illustrated before here. But if you are new to this, record a macro in
Excel which opens a workbook and saves it in the format you want. Excel
will create a bunch of VBA for you that is the recorded macro. You can save
the module as a text file in the VB Editor view of Excel's macros. Then
open your Access project (database, whatever) and in a module start things
off with:

Private appExcel as new Excel.Application.

You will need a reference to the Office type library to make this work.
Click on Tools | References in the VB Editor to get the dialog box where
references are selected. Make sure something like the Office X type library
is selected.

Now you can take the VBA code generated by Excel and paste it into a
procedure in your Access module. There is a bit more work to clean up the
code so it uses your appExcel instance to run everything. But after that
the rest should be pretty easy.

--
Alan Webb
kn*******@SPAMhotmail.com
"It's not IT, it's IS"

"Marcus" <to*******@yahoo.ca> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Would you happen to have any samples of this, or know where I could
find samples on this?

Marcus
*******

Nov 13 '05 #4
Marcus,
And . . . the reason I didn't send sample code is I draw the line at usable
code that doesn't need additional work. I am willing as a teacher to
provide examples that point someone in the right direction but if you want
me to do all the work then that's consulting and I charge for that.
--
Alan Webb
kn*******@SPAMhotmail.com
"It's not IT, it's IS"

"Marcus" <to*******@yahoo.ca> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Would you happen to have any samples of this, or know where I could
find samples on this?

Marcus
*******

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike Wilson | last post by:
Is there a way to open an OLE DB database from within Access? I would like to use the Access GUI with its table and query explorer to examine a database only available through an OLEDB provider...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
4
by: Vishal | last post by:
Hello, I have a dataset with some content. I can convert this dataset in a csv format which is then stored in a stringwriter. Now I want this be open via excel, so I set the contenttype...
4
by: Josh Behl | last post by:
When I try to programmatically open an existing Excel document using a custom windows form, it works perfectly. I instanciate a new instance of the Excel.ApplicationClass and then set the Visible...
3
by: Donald Grove | last post by:
I need to get data from a table in .dbf format. I try importing it, but get "external table not in expected format". So I tried this VB code to see if I could get at my records with ADO (which...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
6
by: Lewe22 | last post by:
I have succesfully exported an Access report to Excel and then opened it, now i want to format it: Private Sub Command2_Click() Dim Date1 Dim stReportAddress As String ...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
8
by: K Viltersten | last post by:
I understand that the new versions of MS Word, MS Excel etc. allow for creation of a document using XML tags (the technique or format is called OOXML, i think). I imagine that the idea behind...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.