Solved

MS Excel SaveAs Without Prompt, VBA MS Access

Posted on 2011-09-07
2
1,196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 81

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

751 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