Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Excel SaveAs Without Prompt, VBA MS Access

Posted on 2011-09-07
2
Medium Priority
?
1,239 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 2000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

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)…
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

730 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