Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
I need my VBA to import a module depending on certain conditions.
Problem is that the project is 'hidden from viewing' with a code, and apparrently this also blocks for modules to be imported! Is there a way to temporary unlock the project, import the module, and then protect the project again? I'm not talking about cracking the project - the code is known... ....just need to temporary allow for a module to be imported by VBA code (the importing code, I already know :-) Thanks in advance... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
There's nothing built into excel/VBA that allows you to unprotect a protected
project. You may be able to search google for techniques that use Sendkeys, but I wouldn't use anything that is as unreliable as that. On 07/03/2011 04:34, Charlotte E wrote: I need my VBA to import a module depending on certain conditions. Problem is that the project is 'hidden from viewing' with a code, and apparrently this also blocks for modules to be imported! Is there a way to temporary unlock the project, import the module, and then protect the project again? I'm not talking about cracking the project - the code is known... ...just need to temporary allow for a module to be imported by VBA code (the importing code, I already know :-) Thanks in advance... -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
hi,
Sub TestUnprotectVBA() 'the password = "a" Workbooks.Open Filename:="C:\temp\MyFile.xls" Call UnprotectVBProject(ActiveWorkbook, "a") End Sub Sub UnprotectVBProject(WB As Workbook, ByVal Password As String) Dim vbProj As Object Set vbProj = WB.VBProject If vbProj.Protection < 1 Then Exit Sub Set Application.VBE.ActiveVBProject = vbProj SendKeys Password & "~~" Application.VBE.CommandBars(1).FindControl(ID:=257 8, _ recursive:=True).Execute End Sub -- isabelle |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
Charlotte E wrote :
I need my VBA to import a module depending on certain conditions. Problem is that the project is 'hidden from viewing' with a code, and apparrently this also blocks for modules to be imported! Is there a way to temporary unlock the project, import the module, and then protect the project again? I'm not talking about cracking the project - the code is known... ...just need to temporary allow for a module to be imported by VBA code (the importing code, I already know :-) Thanks in advance... Is there some reason the module can't be included in the project and only use its code under certain conditions? -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
Is there some reason the module can't be included in the project and only
use its code under certain conditions? It contains XL2007 code, which won't complie under XL2003 - so, I check for Application.Version, and import the module if Version is 11. Works like a charm :-) Unless if project is hidden from viewing :-( CE "GS" wrote in message ... Charlotte E wrote : I need my VBA to import a module depending on certain conditions. Problem is that the project is 'hidden from viewing' with a code, and apparrently this also blocks for modules to be imported! Is there a way to temporary unlock the project, import the module, and then protect the project again? I'm not talking about cracking the project - the code is known... ...just need to temporary allow for a module to be imported by VBA code (the importing code, I already know :-) Thanks in advance... Is there some reason the module can't be included in the project and only use its code under certain conditions? -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
Thanks - I'll look at it tonight when I back :-)
CE "isabelle" wrote in message ... hi, Sub TestUnprotectVBA() 'the password = "a" Workbooks.Open Filename:="C:\temp\MyFile.xls" Call UnprotectVBProject(ActiveWorkbook, "a") End Sub Sub UnprotectVBProject(WB As Workbook, ByVal Password As String) Dim vbProj As Object Set vbProj = WB.VBProject If vbProj.Protection < 1 Then Exit Sub Set Application.VBE.ActiveVBProject = vbProj SendKeys Password & "~~" Application.VBE.CommandBars(1).FindControl(ID:=257 8, _ recursive:=True).Execute End Sub -- isabelle |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
"Charlotte E" wrote in message
... Is there some reason the module can't be included in the project and only use its code under certain conditions? It contains XL2007 code, which won't complie under XL2003 - so, I check for Application.Version, and import the module if Version is 11. Works like a charm :-) Unless if project is hidden from viewing :-( Sounds to me like a place for conditional compiler code ... no time to pull up an example just now; reply if you want more information. Open up the VBE and enter conditional compile in the help box. -- Clif CE "GS" wrote in message ... Charlotte E wrote : I need my VBA to import a module depending on certain conditions. Problem is that the project is 'hidden from viewing' with a code, and apparrently this also blocks for modules to be imported! Is there a way to temporary unlock the project, import the module, and then protect the project again? I'm not talking about cracking the project - the code is known... ...just need to temporary allow for a module to be imported by VBA code (the importing code, I already know :-) Thanks in advance... Is there some reason the module can't be included in the project and only use its code under certain conditions? -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc -- Clif McIrvin (clare reads his mail with moe, nomail feeds the bit bucket :-) |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
Charlotte E brought next idea :
Is there some reason the module can't be included in the project and only use its code under certain conditions? It contains XL2007 code, which won't complie under XL2003 - so, I check for Application.Version, and import the module if Version is 11. Works like a charm :-) Unless if project is hidden from viewing :-( CE "GS" wrote in message ... Charlotte E wrote : I need my VBA to import a module depending on certain conditions. Problem is that the project is 'hidden from viewing' with a code, and apparrently this also blocks for modules to be imported! Is there a way to temporary unlock the project, import the module, and then protect the project again? I'm not talking about cracking the project - the code is known... ...just need to temporary allow for a module to be imported by VBA code (the importing code, I already know :-) Thanks in advance... Is there some reason the module can't be included in the project and only use its code under certain conditions? -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc Ok. So what I do is make a 'plugin' addin to my addin, so if your 'core' addin detects =XL12 then open the 'plugin' addin and have its menus added to yours. This will allow you to use Workbooks.Open as normal, and you can store the xlam in the same folder as your xla. -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
Charlotte,
It contains XL2007 code, which won't complie under XL2003 - so, I check for Application.Version, and import the module if Version is 11. If the prohect is locked it's tricky to lock & relock. It can be done without SendKeys but overkill for your purposes. Even if the project is not locked User's security settings will need to "trust access to VBProject" There are workarounds, it depends what you are doing but the simplest is don't fully declare any objects that prefix later version stuff, eg Dim rng as Range, oRng as Object If vers <=11 then set rng = rng.2003-stuff Else Set oRng = oRng.2007/2010-stuff Set rng = oRng End if That's contrived just for ideas, maybe different procedures for 2003 / 2007. Clif, Sounds to me like a place for conditional compiler code ... no time to pull up an example just now; reply if you want more information. Open up the VBE and enter conditional compile in the help box. Problem is you can't change the conditional arguments after distributing without access to the project, in effect back to square one. Peter Thornton |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import module
"Peter T" wrote in message
... Charlotte, It contains XL2007 code, which won't complie under XL2003 - so, I check for Application.Version, and import the module if Version is 11. [ ] Clif, Sounds to me like a place for conditional compiler code ... no time to pull up an example just now; reply if you want more information. Open up the VBE and enter conditional compile in the help box. Problem is you can't change the conditional arguments after distributing without access to the project, in effect back to square one. Peter Thornton Ahh .. I see my error now. In my haste I <conveniently forgot that conditional directives can test only constants or literals. Thanks for the catch! -- Clif McIrvin (clare reads his mail with moe, nomail feeds the bit bucket :-) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
import existing module | Excel Programming | |||
Import Module to New Workbook | Excel Programming | |||
Import Module | Excel Programming | |||
Import useerfom, module in .xlt | Excel Programming | |||
Import module with vba | Excel Programming |