Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it possible to write code to open an excel workbook,
access the code (that is password protected), perform a Find/Replace All, and close the workbook, saving changes? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It's possible to open an Excel workbook and edit the code - but, AFAIK, only
if the code is not protected. I don't think there is anyway programatically to unprotect the code, even if you know the password. Tim "Sam" wrote in message ... Is it possible to write code to open an excel workbook, access the code (that is password protected), perform a Find/Replace All, and close the workbook, saving changes? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() PS - for info on how to programatically edit modules etc see Chip Pearson's website at: http://www.cpearson.com/excel/vbe.htm Tim "Tim Barlow" wrote in message ... It's possible to open an Excel workbook and edit the code - but, AFAIK, only if the code is not protected. I don't think there is anyway programatically to unprotect the code, even if you know the password. Tim "Sam" wrote in message ... Is it possible to write code to open an excel workbook, access the code (that is password protected), perform a Find/Replace All, and close the workbook, saving changes? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sam,
Assuming your code is unprotected, you could use this code: I've added a second condition so that it doesn't modify it's own procedure (Not .ProcOfLine(i, vbext_pk_Proc) = "testit" ) Sub testit() Dim strFind As String, strReplace As String, vbc As VBComponent, i As Long, j As Long strFind = "drink me" strReplace = "eat me" For Each vbc In ThisWorkbook.VBProject.VBComponents With vbc.CodeModule For i = 1 To .CountOfLines j = InStr(1, .Lines(i, 1), strFind, vbTextCompare) If j 0 And Not .ProcOfLine(i, vbext_pk_Proc) = "testit" Then _ .ReplaceLine i, Replace(.Lines(i, 1), strFind, strReplace, , , vbTextCompare) Next End With Next End Sub Cheers "Sam" wrote in message ... Is it possible to write code to open an excel workbook, access the code (that is password protected), perform a Find/Replace All, and close the workbook, saving changes? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
edit & configure add button & code | Excel Discussion (Misc queries) | |||
Edit this macro code to loop and end | Excel Discussion (Misc queries) | |||
edit hyperlink code cont from 12/8/04 | Excel Discussion (Misc queries) | |||
Can I edit .iqy file from code? | Excel Programming | |||
Code Edit | Excel Programming |