A
azmene
Hi-
I apologize for the length of this message in advance. I wanted to be
as detailed as possible.
I need to have the ability to export an Access query into an existing
Excel workbook and replace the same worksheet within that workbook
each time I export (I do not have range restrictions within the
worksheet). On my home computer, which has an older version of Excel,
I can just use Access' macro transferspreadsheet action and the export
replaces the existing Excel spreadsheet. However, at work, I have a
newer version of Excel so when I run the transferspreadsheet action a
new worksheet is created rather than replacing the existing
worksheet. I cannot use the output to function as I have some lookups
within the same workbook that feed off of the existing spreadsheet.
My questions are:
1) Will the transferspreadsheet method command in VBA replace the
existing table or will it create a new worksheet if a worksheet with
the same name as the export exists within the workbook like the
transferspreadsheet action does?
2) If creating a module will do the trick, how exactly would I go
about creating a module (as I've never worked with VBA before, I would
need step by step directions, even as simple as open access, go to
modules, create new, etc)?
3) If I can use a VBA code, how can I include a command to run the
module in a macro if it is not the run code command? If it is by
using the run code command, is there a specific name I should save the
module as in order to use the run code command in macro, and how do I
property set up the run code command so that it will run the module?
I would prefer to use VBA as little as possible given my inexperience
with it, which is why I would like to be able to use a macro to run
the module.
4) Does using the transferworksheet method in VBA require the file
path of the export to be on the C drive? At work I need it to export
to a folder on the network.
5) If creating a module with the transferspreadsheet command will not
do as I need, is there another access command I can use that will, or
is there some way to overwrite the program's need to create a new
spreadsheet if the spreadsheet name already exists within the file I'm
exporting to?
Please be as specific as possible with details, as my attempts to use
other posts to create the DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel5, "your table name", "c:/temp/result.xls", 0 as
a Function returns a message that an expression is expected or only
opens up the module in design view when I try to run it.
Appreciate any help I can get with these issues!
I apologize for the length of this message in advance. I wanted to be
as detailed as possible.
I need to have the ability to export an Access query into an existing
Excel workbook and replace the same worksheet within that workbook
each time I export (I do not have range restrictions within the
worksheet). On my home computer, which has an older version of Excel,
I can just use Access' macro transferspreadsheet action and the export
replaces the existing Excel spreadsheet. However, at work, I have a
newer version of Excel so when I run the transferspreadsheet action a
new worksheet is created rather than replacing the existing
worksheet. I cannot use the output to function as I have some lookups
within the same workbook that feed off of the existing spreadsheet.
My questions are:
1) Will the transferspreadsheet method command in VBA replace the
existing table or will it create a new worksheet if a worksheet with
the same name as the export exists within the workbook like the
transferspreadsheet action does?
2) If creating a module will do the trick, how exactly would I go
about creating a module (as I've never worked with VBA before, I would
need step by step directions, even as simple as open access, go to
modules, create new, etc)?
3) If I can use a VBA code, how can I include a command to run the
module in a macro if it is not the run code command? If it is by
using the run code command, is there a specific name I should save the
module as in order to use the run code command in macro, and how do I
property set up the run code command so that it will run the module?
I would prefer to use VBA as little as possible given my inexperience
with it, which is why I would like to be able to use a macro to run
the module.
4) Does using the transferworksheet method in VBA require the file
path of the export to be on the C drive? At work I need it to export
to a folder on the network.
5) If creating a module with the transferspreadsheet command will not
do as I need, is there another access command I can use that will, or
is there some way to overwrite the program's need to create a new
spreadsheet if the spreadsheet name already exists within the file I'm
exporting to?
Please be as specific as possible with details, as my attempts to use
other posts to create the DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel5, "your table name", "c:/temp/result.xls", 0 as
a Function returns a message that an expression is expected or only
opens up the module in design view when I try to run it.
Appreciate any help I can get with these issues!