Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tj tj is offline
external usenet poster
 
Posts: 71
Default New Workbook through VBA

Hi,

I was wondering if anyone can guide me on how create a new workbook from
Access for excel using VBA.

I tried the following, but it gives me an error: Run Time error - 2302 -
Microsoft Access can't save the output data to the file you've selected

DoCmd.OutputTo acOutputTable, "TBL_USERS", acFormatXLS, FileNameArray(index)

FileNameArray is an array with the names of the file. Initially i thought
the array could be empty, but it isn't.

Will appreciate an idea, or an alternate code that might be helpful.

Thanks,

Ali




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default New Workbook through VBA

Ali

It's almost always because the path to the file is invalid. The use of the
array should not be causing a problem. When you get the error, open the
Debug window and type

?Dir(FileNameArray(index))

If you get an empty string, the path isn't right.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Tj wrote:
Hi,

I was wondering if anyone can guide me on how create a new workbook
from Access for excel using VBA.

I tried the following, but it gives me an error: Run Time error -
2302 - Microsoft Access can't save the output data to the file you've
selected

DoCmd.OutputTo acOutputTable, "TBL_USERS", acFormatXLS,
FileNameArray(index)

FileNameArray is an array with the names of the file. Initially i
thought the array could be empty, but it isn't.

Will appreciate an idea, or an alternate code that might be helpful.

Thanks,

Ali



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default New Workbook through VBA

The syntax is correct. My guess is that your FileNameArray(index) argument
is the issue. It needs to return a string filename such as "MyFile.xls" or
"C:\Temp\MyFile.xls". If not, the DoCmd will fail.

Simple code...
index = 1
FileNameArray(index)="MyFile.xls"
DoCmd.OutputTo acOutputTable, "TBL_USERS", acFormatXLS, FileNameArray(index)

HTH,
--
Gary Brown

Please rate this posting if it is helpful to you.


"Tj" wrote:

Hi,

I was wondering if anyone can guide me on how create a new workbook from
Access for excel using VBA.

I tried the following, but it gives me an error: Run Time error - 2302 -
Microsoft Access can't save the output data to the file you've selected

DoCmd.OutputTo acOutputTable, "TBL_USERS", acFormatXLS, FileNameArray(index)

FileNameArray is an array with the names of the file. Initially i thought
the array could be empty, but it isn't.

Will appreciate an idea, or an alternate code that might be helpful.

Thanks,

Ali




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh pivot table in workbook A when changing a cell in workbook gildengorin Excel Worksheet Functions 2 March 17th 09 04:59 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"