Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Removing Module Protection Programatically
We are trying to push some new code to the our code modules in a workbook.
The issue we face right now is that the modules are protected. Is there a way to programmatically remove the module protection. So that I can run the bellow code so that I do not get an error accessing the protected modules. Sub PatchWorkbook(PatchWBPath As String) Dim ve As VBE Dim xl As Excel.Application Dim wb As Workbook Dim codeModule As codeModule Set xl = New Excel.Application xl.EnableEvents = False xl.DisplayAlerts = False Set wb = xl.Workbooks.Open(PatchWBPath, False, False, , "", "", , , , , False) wb.UpdateRemoteReferences = False xl.Calculation = xlCalculationManual Set ve = xl.VBE Debug.Print ve.VBProjects(1).Protection Set codeModule = ve.ActiveVBProject.VBComponents("ThisWorkbook") wb.Save wb.Close Set wb = Nothing Set xl = Nothing End Sub Thanks in advance! Reg, Adam |
#2
|
|||
|
|||
Adam wrote...
We are trying to push some new code to the our code modules in a workbook. The issue we face right now is that the modules are protected. Is there a way to programmatically remove the module protection. So that I can run the bellow code so that I do not get an error accessing the protected modules. .... Read the archived thread linked below. http://groups-beta.google.com/group/...cf7803979b9815 (or http://makeashorterlink.com/?P5192144A ) |
#3
|
|||
|
|||
Thanks Harlan, I wish I didn't have to go down the road of SendKeys...but...I
guess it is my only option. "Harlan Grove" wrote: Adam wrote... We are trying to push some new code to the our code modules in a workbook. The issue we face right now is that the modules are protected. Is there a way to programmatically remove the module protection. So that I can run the bellow code so that I do not get an error accessing the protected modules. .... Read the archived thread linked below. http://groups-beta.google.com/group/...cf7803979b9815 (or http://makeashorterlink.com/?P5192144A ) |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Removing Module Protection Programatically
I need to add a macro to a distributed workbook and found your response. I
looked at your reference and tried using the following code, but it does not work. I did check the MBVE reference mentioned by Tom Oglivy, but still no job. Here's the code I'm using: Sub TryToUnlock() Dim WB As Workbook Set WB = Workbooks("TestOpen.xls") UnprotectVBProject WB End Sub Sub UnprotectVBProject(WB As Workbook) ', ByVal Password As String) ' Bill Manville, 29-Jan-2000 ' Dim VBP As VBProject, oWin As VBIDE.Window Dim wbActive As Workbook Dim i As Integer Set VBP = WB.VBProject Set wbActive = ActiveWorkbook If VBP.Protection < vbext_pp_locked Then Exit Sub Application.ScreenUpdating = False ' close any code windows to ensure we hit the right project For Each oWin In VBP.VBE.Windows If InStr(oWin.Caption, "(") 0 Then oWin.Close Next oWin WB.Activate ' now use lovely SendKeys to unprotect Application.OnKey "%{F11}" SendKeys "%{F11}%TE", True '& Password & "~~%{F11}", True 'If VBP.Protection = vbext_pp_locked Then ' failed - maybe wrong password ' SendKeys "%{F11}%TE", True 'End If End Sub "Harlan Grove" wrote: Adam wrote... We are trying to push some new code to the our code modules in a workbook. The issue we face right now is that the modules are protected. Is there a way to programmatically remove the module protection. So that I can run the bellow code so that I do not get an error accessing the protected modules. .... Read the archived thread linked below. http://groups-beta.google.com/group/...cf7803979b9815 (or http://makeashorterlink.com/?P5192144A ) |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Removing Module Protection Programatically
Hello all, Here is my solution http://www.ozgrid.com/forum/showthre...t=13006&page=2 You can download the '*JB Word components exporter.zip*' archive. It contents the source code. hf ;) -- gg67 ------------------------------------------------------------------------ gg67's Profile: http://www.excelforum.com/member.php...o&userid=33548 View this thread: http://www.excelforum.com/showthread...hreadid=336694 |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Removing Module Protection Programatically
I am sure you will be very popular with people who make add-ins as part of
their living -- Regards, Peo Sjoblom Excel 95 - Excel 2007 Northwest Excel Solutions www.nwexcelsolutions.com "It is a good thing to follow the first law of holes; if you are in one stop digging." Lord Healey "gg67" wrote in message ... Hello all, Here is my solution http://www.ozgrid.com/forum/showthre...t=13006&page=2 You can download the '*JB Word components exporter.zip*' archive. It contents the source code. hf ;) -- gg67 ------------------------------------------------------------------------ gg67's Profile: http://www.excelforum.com/member.php...o&userid=33548 View this thread: http://www.excelforum.com/showthread...hreadid=336694 |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
Removing Module Protection Programatically
I don't see it...could you point me to the right place?
"gg67" wrote: Hello all, Here is my solution http://www.ozgrid.com/forum/showthre...t=13006&page=2 You can download the '*JB Word components exporter.zip*' archive. It contents the source code. hf ;) -- gg67 ------------------------------------------------------------------------ gg67's Profile: http://www.excelforum.com/member.php...o&userid=33548 View this thread: http://www.excelforum.com/showthread...hreadid=336694 |
#9
Posted to microsoft.public.excel.misc
|
|||
|
|||
Removing Module Protection Programatically
Peo Sjoblom wrote: I am sure you will be very popular with people who make add-ins as part of their living I just hoped to be able to help somebody, in all modesty... David, look at the bottom of the page. Or you can directly download the attached file here. hf ;) +-------------------------------------------------------------------+ |Filename: JB Word components exporter.zip | |Download: http://www.excelforum.com/attachment.php?postid=4645 | +-------------------------------------------------------------------+ -- gg67 ------------------------------------------------------------------------ gg67's Profile: http://www.excelforum.com/member.php...o&userid=33548 View this thread: http://www.excelforum.com/showthread...hreadid=336694 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Difference in the listing of the New module addition in 2002 version | Excel Discussion (Misc queries) | |||
General protection fault in module HPPCL5F4.DLL at 0002:000006c2. | Excel Discussion (Misc queries) | |||
Access Module coded converted to Excel Function | Excel Discussion (Misc queries) | |||
EXCELL Protection | Excel Discussion (Misc queries) | |||
How may I remove Office 2003 DRM protection from DOC & XLS files? | Excel Discussion (Misc queries) |