Change a line of code programatically

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,644
Office Version
  1. 365
Platform
  1. Windows
I hgave about 250 files in a folder and I need to change 1 line of code in one of the modules.

Rather than opening each file is there a way of looping through all the files and changing the line with a macro?


Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
That helps with part of what I need to do but it doesn't actually tell me how tho amend specific rows in a module.
 
Upvote 0
Can we count on the line resinding in the same named procedure (no variance in versions of the code) and is the procedure in the consistently same named module?
 
Upvote 0
Nailed
Code:
    Set VBProj = Application.Workbooks(wbWorkbook.Name).VBProject
    Set VBComp = VBProj.VBComponents("AreaWorkbook_Printing")
    Set CodeMod = VBComp.CodeModule
    
    With CodeMod
        .DeleteLines 270, 1
        .InsertLines 270, "    .Zoom = False"
    End With

Thanks for the pointer though :D
 
Upvote 0
Glad you got it :-) Just as FYI, you may wish to check .ReplaceLine for a one-stepper.
 
Upvote 0
Thankls GTO, thought they would be something that could do it with one line.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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