VBA - Remove VBA when the file changes name

AllanA

New Member
Joined
Sep 26, 2014
Messages
1
I would like to remove/disable the VBA code that is in an xlsm file that will be used to import and analyse data, its then saved as a different file name. But when you open that file it tries to re-import the data again as these file will be opened by many people I can not guarantee that they macro's disabled or external data. The code is: Private Sub Workbook_Open()
ActiveWorkbook.Connections("Demo").Refresh
End Sub I'm using the code as Winautomation is processing the file and the import doesn't work if I use the property setting within the Data Wizard, but with the above code it does. Is there a way of adding workbook name into the above code so it on works if that particular workbook is open??
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Why not just save it as an .xlsx file when you save it under another name - then there won't be any code in it.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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
Back
Top