Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dealing with windows msg boxs

Status
Not open for further replies.

Tido

Programmer
Jul 18, 2002
8
0
0
CA
I have written an app that exports access query results into an excel spreadsheet but when/if i try to overwrite the excel file im exporting the results to the program crashs while running the
oExApp.Workbooks(1).SaveAs txtFileName.Text
line only if i choose cancel or no in the windows msg box that shows up asking if i want to overwrite the file
 
The situation that describing is certainly not normal, and is indicative of something not right maybe with Excel, maybe not.

However, in your code, you might be able to use the following work around:

Prior to the .SaveAs call, check using the Dir function for the existance of the file.

If it exists, use the intrinsic MsgBox function to ask the user to overwrite, and if so, use the Kill function to delete the file. Then call the .SaveAs method.

If it doesn't exist, then call the .SaveAs method. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top