Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Store code outside the workbook, is it possible?
Is it possible to store a module (maybe export it and keep it in a specific
location), then 'call' it from the workbook. So it would be like having a text file in a folder on your c drive and then instgructing the code to copy the string and use it as a string variable in the code and run it from within another sub. e.g. Sub GetOutsideCode Dim sCode As String sCode = TextFileInSpecifiedFolder.Contents Call sCode End sub or some such thing. I know it used to be possible to get values from a closed workbook using GetValue with excel 2003, don't know if it's still available in 2007 (anyone know?) but it strikes me that if it is and my idea above won't work, then storing the code in cells in a workbook should produce the same end result. One of my reasons for wanting to do this is that in order to protect intellectual property in an excel workbook it could be possible to have the file containing the code in the specified folder and then kill it at a specified interval unless a passwrod was entered before that interval. Bit of a whacky idea maybe but it should work well enough for the audience i have in mind. Thanks and regards, Mark |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Store code outside the workbook, is it possible?
The best way is probably to include it, but use VB protection not just
workbook protection. Have a userform pop up everytime they open it if they have not entered a password, something like Dim showForm as Boolean showForm=True on load event If showForm=True then form1.show end if Then you can either put a counter that increments everytime they click the ok button without putting in the code, once it hits a limit it will no longer be enabled without the code, or set the button to disable if there is no valid code. on form load If myCounter3 then form1.commandbutton1.enabled=false on for button click If form1.textbox1.text <"Password" then myCounter=myCounter+1 end if hope that gets you started -- -John Please rate when your question is answered to help us and others know what is helpful. "Mark Stephens" wrote: Is it possible to store a module (maybe export it and keep it in a specific location), then 'call' it from the workbook. So it would be like having a text file in a folder on your c drive and then instgructing the code to copy the string and use it as a string variable in the code and run it from within another sub. e.g. Sub GetOutsideCode Dim sCode As String sCode = TextFileInSpecifiedFolder.Contents Call sCode End sub or some such thing. I know it used to be possible to get values from a closed workbook using GetValue with excel 2003, don't know if it's still available in 2007 (anyone know?) but it strikes me that if it is and my idea above won't work, then storing the code in cells in a workbook should produce the same end result. One of my reasons for wanting to do this is that in order to protect intellectual property in an excel workbook it could be possible to have the file containing the code in the specified folder and then kill it at a specified interval unless a passwrod was entered before that interval. Bit of a whacky idea maybe but it should work well enough for the audience i have in mind. Thanks and regards, Mark |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Store code outside the workbook, is it possible?
Hi Mark
I think the safest way to do this is to save your code in an addin file (xla) and run it from another workbook like this: Sub Tester() Dim wb As Workbook Set wb = Workbooks.Open("C:\Temp\Test.xla", ReadOnly:=True) DoEvents Application.Run (wb.Name & "!Macro1") DoEvents wb.Saved = True wb.Close End Sub HTH. Best wishes Harald "Mark Stephens" skrev i melding ... Is it possible to store a module (maybe export it and keep it in a specific location), then 'call' it from the workbook. So it would be like having a text file in a folder on your c drive and then instgructing the code to copy the string and use it as a string variable in the code and run it from within another sub. e.g. Sub GetOutsideCode Dim sCode As String sCode = TextFileInSpecifiedFolder.Contents Call sCode End sub or some such thing. I know it used to be possible to get values from a closed workbook using GetValue with excel 2003, don't know if it's still available in 2007 (anyone know?) but it strikes me that if it is and my idea above won't work, then storing the code in cells in a workbook should produce the same end result. One of my reasons for wanting to do this is that in order to protect intellectual property in an excel workbook it could be possible to have the file containing the code in the specified folder and then kill it at a specified interval unless a passwrod was entered before that interval. Bit of a whacky idea maybe but it should work well enough for the audience i have in mind. Thanks and regards, Mark |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Store code outside the workbook, is it possible?
Thanks for that Harald, I forgot about add ins that's pretty much what
they're designed for right Kind regards, Mark "Harald Staff" wrote in message ... Hi Mark I think the safest way to do this is to save your code in an addin file (xla) and run it from another workbook like this: Sub Tester() Dim wb As Workbook Set wb = Workbooks.Open("C:\Temp\Test.xla", ReadOnly:=True) DoEvents Application.Run (wb.Name & "!Macro1") DoEvents wb.Saved = True wb.Close End Sub HTH. Best wishes Harald "Mark Stephens" skrev i melding ... Is it possible to store a module (maybe export it and keep it in a specific location), then 'call' it from the workbook. So it would be like having a text file in a folder on your c drive and then instgructing the code to copy the string and use it as a string variable in the code and run it from within another sub. e.g. Sub GetOutsideCode Dim sCode As String sCode = TextFileInSpecifiedFolder.Contents Call sCode End sub or some such thing. I know it used to be possible to get values from a closed workbook using GetValue with excel 2003, don't know if it's still available in 2007 (anyone know?) but it strikes me that if it is and my idea above won't work, then storing the code in cells in a workbook should produce the same end result. One of my reasons for wanting to do this is that in order to protect intellectual property in an excel workbook it could be possible to have the file containing the code in the specified folder and then kill it at a specified interval unless a passwrod was entered before that interval. Bit of a whacky idea maybe but it should work well enough for the audience i have in mind. Thanks and regards, Mark |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Store code outside the workbook, is it possible?
Hi John,
Thanks for that an ingenious idea which will achieve my aim, kind regards, Mark "John Bundy" (remove) wrote in message ... The best way is probably to include it, but use VB protection not just workbook protection. Have a userform pop up everytime they open it if they have not entered a password, something like Dim showForm as Boolean showForm=True on load event If showForm=True then form1.show end if Then you can either put a counter that increments everytime they click the ok button without putting in the code, once it hits a limit it will no longer be enabled without the code, or set the button to disable if there is no valid code. on form load If myCounter3 then form1.commandbutton1.enabled=false on for button click If form1.textbox1.text <"Password" then myCounter=myCounter+1 end if hope that gets you started -- -John Please rate when your question is answered to help us and others know what is helpful. "Mark Stephens" wrote: Is it possible to store a module (maybe export it and keep it in a specific location), then 'call' it from the workbook. So it would be like having a text file in a folder on your c drive and then instgructing the code to copy the string and use it as a string variable in the code and run it from within another sub. e.g. Sub GetOutsideCode Dim sCode As String sCode = TextFileInSpecifiedFolder.Contents Call sCode End sub or some such thing. I know it used to be possible to get values from a closed workbook using GetValue with excel 2003, don't know if it's still available in 2007 (anyone know?) but it strikes me that if it is and my idea above won't work, then storing the code in cells in a workbook should produce the same end result. One of my reasons for wanting to do this is that in order to protect intellectual property in an excel workbook it could be possible to have the file containing the code in the specified folder and then kill it at a specified interval unless a passwrod was entered before that interval. Bit of a whacky idea maybe but it should work well enough for the audience i have in mind. Thanks and regards, Mark |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Store code outside the workbook, is it possible?
For code protection I think the best way is to move your code to VB6, so to
an ActiveX dll file. You will need to buy VB6, but it is very simple to move code over and there are other benefits in using VB6 as well. RBS "Mark Stephens" wrote in message ... Is it possible to store a module (maybe export it and keep it in a specific location), then 'call' it from the workbook. So it would be like having a text file in a folder on your c drive and then instgructing the code to copy the string and use it as a string variable in the code and run it from within another sub. e.g. Sub GetOutsideCode Dim sCode As String sCode = TextFileInSpecifiedFolder.Contents Call sCode End sub or some such thing. I know it used to be possible to get values from a closed workbook using GetValue with excel 2003, don't know if it's still available in 2007 (anyone know?) but it strikes me that if it is and my idea above won't work, then storing the code in cells in a workbook should produce the same end result. One of my reasons for wanting to do this is that in order to protect intellectual property in an excel workbook it could be possible to have the file containing the code in the specified folder and then kill it at a specified interval unless a passwrod was entered before that interval. Bit of a whacky idea maybe but it should work well enough for the audience i have in mind. Thanks and regards, Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
store active workbook | Excel Programming | |||
Code to track changes by row and store | Excel Programming | |||
Store Active Workbook | Excel Discussion (Misc queries) | |||
Store FilePath Inside Code | Excel Programming | |||
Store Information but not in a Workbook | Excel Programming |