|
-
Sep 29th, 2005, 07:14 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Overwriting files
Ok, I am using oWorkBook.SaveAs to tell Excel to save a workbook. The file already exists, since I had to open it to make the changes in the first place, and I want to always overwrite the file when I'm done. Is there any way to either supress the overwrite prompt or tell it to yes always overwrite from inside the program? If I have to click yes on that prompt after every single transaction I process it will be a pain.
And before you ask, yes, I need to save it after each one, because it pulls the information that goes into the sheets off a form that is changed from one transaction to the next.
If you need to see the code, let me know.
-
Sep 29th, 2005, 09:17 PM
#2
Re: Overwriting files
You can do it either way...
VB Code:
Application.DisplayAlerts = False
Application.Workbooks("Book1.xls").Save
Application.Workbooks("Book1.xls").Saved = True
Application.Workbooks("Book1.xls").Close
Application.DisplayAlerts = True
'Or
Application.DisplayAlerts = False
Application.Workbooks("Book1.xls").Close SaveChanges:=True, Filename:="C:\Book1.xls"
Application.DisplayAlerts = True
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 29th, 2005, 09:54 PM
#3
Thread Starter
Addicted Member
Re: Overwriting files
I ended up doing it this way and it works fine:
VB Code:
Application.DisplayAlerts = False ' turn off overwrite prompt
oBook.SaveAs ("C:\FHR\StableBankAccounts.xls")
Application.DisplayAlerts = True
I'm using SaveAs so it will stay compatibel with Execl 97 (this is being done in Excel 2000).
-
Sep 29th, 2005, 10:29 PM
#4
Re: [RESOLVED] Overwriting files
You need to verify that your book is getting the updates applied because when turning of displayalerts it accepts the defaults on the supressed message box. The "No" is the default.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 29th, 2005, 10:31 PM
#5
Thread Starter
Addicted Member
Re: [RESOLVED] Overwriting files
Oh, I did. I loaded the sheet into Excel 97 and verified that the right stuff was put in the right cells, and it's all working fine. I'm really pleased with how this project is coming along.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|