Solved

Help with arguments for Excel.Workbook.SaveAs function

Posted on 2006-06-30
2
716 Views
Last Modified: 2008-01-09
Hello gurus,

I am trying to add a line to a VB function in Access. The function actually builds an excel spreadsheet. I want to overwrite an existing excel file with the newly built one everytime the script is run. I just can't get excel to stop prompting me about overwriting an exsiting file. Is there an argument to the SaveAs method that can turn off prompting?

My current code is:

    directory = "H:\Daily Numbers\" & Year(Now()) & "\" & MonthName(Month(Now())) & " " & Year(Now())
    ChDir (directory)
    ActiveWorkbook.SaveAs FileName:= _
        directory & "\Monthly Reporting " & MonthName(Month(Now())) & " " & Year(Now()) & "_DB.xls", _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False


Thanks in advance.
0
Comment
Question by:gdrnec
[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 5

Accepted Solution

by:
lunchbyte earned 250 total points
ID: 17020601
Try this

if dir(directory & "\Monthly Reporting " & MonthName(Month(Now())) & " " & Year(Now()) & "_DB.xls") <> "" then kill directory & "\Monthly Reporting " & MonthName(Month(Now())) & " " & Year(Now()) & "_DB.xls"

    ActiveWorkbook.SaveAs FileName:= _
        directory & "\Monthly Reporting " & MonthName(Month(Now())) & " " & Year(Now()) & "_DB.xls", _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False

0
 
LVL 4

Author Comment

by:gdrnec
ID: 17020614
I'll have to test it later. I don't know why I didn't think of removing the file first.
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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