Change Part Of Before Save Code In Bulk?

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,398
Office Version
2016
Platform
Windows
I have loads of files that have a before save code within them. I need to change the location, is it possible to change part of the code without opening them all individually?

This is the code

Rich (BB code):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)


    If MsgBox("Save?", vbYesNo, "Confirm") = vbNo Then Exit Sub
   Application.DisplayAlerts = False
    ActiveSheet.Copy
   ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\MANAGER\Desktop\Darrens Catalogues\Suspension_Catalog2.1A.csv", FileFormat:=xlCSV, CreateBackup:=False
    ActiveWorkbook.Close False
End Sub
All I need to change is the 'Manager' in red to Manager1!

From another code I have it uses [FONT=Helvetica, Arial, Verdana, sans-serif]ADO connection and SQL that doesn't open the files is it possible here?[/FONT]
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,398
Office Version
2016
Platform
Windows
Is anyone able to help with this please?
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,846
Office Version
2016
Platform
Windows
Have you considered using the VBExtensibility library ?

Edit:
But that would open the files. However you could temporarly disable the application events, open the files, make the changes , save and close ... I think you could even have the excel files opened in another hidden instance of excel .
 
Last edited:

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,398
Office Version
2016
Platform
Windows
Have you considered using the VBExtensibility library ?

Edit:
But that would open the files. However you could temporarly disable the application events, open the files, make the changes , save and close ... I think you could even have the excel files opened in another hidden instance of excel .
Thanks for the reply but I don't understand it!!

It doesn't matter if the code opens, makes the changes and closes them again.
 
Last edited:

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,653
Office Version
365
Platform
Windows
Cross-posted: https://www.ozgrid.com/forum/forum/...19685-change-part-of-before-save-code-in-bulk

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,436
Messages
5,486,876
Members
407,567
Latest member
spinitback

This Week's Hot Topics

Top