472,354 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 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 1692
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...

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.