Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Optimising vba programming in Excel

Hi there

I'd be most grateful for pointers in the right direction, on how to optimise
my Excel VBA program, that goes back and forth to an Access DB. At the
moment, I don't feel I've done enough with the instantiating and/or closing
of objects - particularly Connection, Catalog and Command Objects.

All the data my Excel program requires, sits in an Access DB. I have a
connection object created, in readiness, whenever the spreadsheet is open. I
close this connection before the workbook closes (using Excel's inherent
BeforeClose Event).

However, after I create an Excel file, from this program, I tried, using
explorer, to delete the created file. I got an error prompt saying:

"Cannot delete xfile. Access is denied. Make sure the disk is not full or
write-protected and that the file is not currently in use."

This error arose despite the fact that the file was not open. It led me to
think that I might still have an object open. However, when I shut Excel down
completely, I was able to delete the file.

What must I pay attention with all the objects I have in my program? If I
use a Command and Catalog object to return a rst, can I close the Command and
Catalog objects immediately after the rst has been returned?

Is it practical to have a Connection open, in expectation of fetching
another rst that the program might require, or should I open one only when
needed?

Any pointers on Dos and Don'ts when working with objects will be greatly
appreciated.

Thanks
ade
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Optimising vba programming in Excel

Hi, please follow these simple rule-of-thumb.
1. Anything that was opened should be closed in the proper order.
2. Close the inner-most objects first and then progress towards outer-most
objects.
The above should save most of the trouble, if not all.

"adewole" wrote:

Hi there

I'd be most grateful for pointers in the right direction, on how to optimise
my Excel VBA program, that goes back and forth to an Access DB. At the
moment, I don't feel I've done enough with the instantiating and/or closing
of objects - particularly Connection, Catalog and Command Objects.

All the data my Excel program requires, sits in an Access DB. I have a
connection object created, in readiness, whenever the spreadsheet is open. I
close this connection before the workbook closes (using Excel's inherent
BeforeClose Event).

However, after I create an Excel file, from this program, I tried, using
explorer, to delete the created file. I got an error prompt saying:

"Cannot delete xfile. Access is denied. Make sure the disk is not full or
write-protected and that the file is not currently in use."

This error arose despite the fact that the file was not open. It led me to
think that I might still have an object open. However, when I shut Excel down
completely, I was able to delete the file.

What must I pay attention with all the objects I have in my program? If I
use a Command and Catalog object to return a rst, can I close the Command and
Catalog objects immediately after the rst has been returned?

Is it practical to have a Connection open, in expectation of fetching
another rst that the program might require, or should I open one only when
needed?

Any pointers on Dos and Don'ts when working with objects will be greatly
appreciated.

Thanks
ade

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
Optimising calculation time [email protected] Excel Discussion (Misc queries) 11 January 15th 09 02:59 PM
optimising column width & row height KRK New Users to Excel 2 March 12th 08 12:35 PM
Help with optimising code FrigidDigit[_2_] Excel Programming 3 October 20th 05 03:37 PM
Optimising portfolios with solver? Oana Excel Programming 1 August 9th 05 10:27 AM
Tips for optimising page setup .Zoom and .FitTo properties Frank_Hamersley Excel Programming 7 June 29th 04 06:08 AM


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

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

About Us

"It's about Microsoft Excel"