Solved

MS Excel SaveAs Without Prompt, VBA MS Access

Posted on 2011-09-07
2
1,168 Views
Last Modified: 2012-05-12
Hello,

I have the following code at the end of a function that edits an Excel spreadsheet within an Access code, VBA:

apExcel.DisplayAlerts = False
    wkBook.SaveAs FileName:=sFileName
apExcel.DisplayAlerts = True

Supposedly, this should save the file without any prompts.  Strangely, it seems to save the file, the prompt again if I want to save the prompt.  I recently upgraded from Access and Excel 2000 to 2010, and this code worked fine with those.  However, everything I read says this should work.

Anyone have any ideas?

Thanks,

0
Comment
Question by:BMIT
2 Comments
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
ID: 36499766
Does the Excel file have a Workbook_BeforeSave macro? If so, that will be triggered by your SaveAs unless you turn events off:
apExcel.EnableEvents = False
apExcel.DisplayAlerts = False
    wkBook.SaveAs FileName:=sFileName
apExcel.DisplayAlerts = True
apExcel.EnableEvents = True

Another possibility is that you try to close the workbook and encounter the Save prompt from that action. You can avoid it with the SaveChanges parameter:
wkBook.Close SaveChanges:=False
0
 

Author Closing Comment

by:BMIT
ID: 36502583
"Another possibility is that you try to close the workbook and encounter the Save prompt from that action. You can avoid it with the SaveChanges parameter:
wkBook.Close SaveChanges:=False"

You hit the nail on the head.  This fixed the issue.

Thanks.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now