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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

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,615
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,101,850
Messages
5,483,299
Members
407,392
Latest member
Mrworldwide

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top