Change Part Of Before Save Code In Bulk?

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,409
Office Version
  1. 2016
Platform
  1. 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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Dazzawm

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

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,115
Office Version
  1. 2016
Platform
  1. 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,409
Office Version
  1. 2016
Platform
  1. 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
55,935
Office Version
  1. 365
Platform
  1. 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,122,737
Messages
5,597,826
Members
414,180
Latest member
Sir Khaya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top