Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
modifying code in run time
i am sure there is an easier way to do this, and if so i'd sure like to know
what it is!! in the meantime, i have an excel file that references a couple of add-ins. it has code that executes on the workbook events and on the worksheet events. (the code just calls code from the add-in). what i would like to be able to do is have to user save it as a "non-application-file" meaning that it won't have the links or code, so they can hand their files off to someone who does not have the application on their system and they may still view it without a bunch of errors. right now, if the user chooses to save the file that way, code excecutes that simply comments out the calls within the workbook. the trick is, when opening the workbook, i would like to check to see if the code is commented out, and if so place a "re-set" button on the menu so it can be re-set to its original form. the code i have to do this is as follows: Private Sub Workbook_Open() Dim lCount As Long Dim bReSet As Boolean Dim vFolderPath As Variant vFolderPath = QueryValue("Software\MyApp\DataLocation", "AddInPath") If IsEmpty(vFolderPath) Then Exit Sub End If lCount = ActiveWorkbook.VBProject.VBE.SelectedVBComponent.C odeModule.CountOfLines bReSet = ActiveWorkbook.VBProject.VBE.SelectedVBComponent.C odeModule.Find("' MyApp", 1, 1, lCount, 1) If bReSet Then ReSetButton MyAppWorkbook_Open End Sub problem #1, the code can not be protected or this does not work. big drawback. problem #2, this doesn't always work! if i run it from design mode, it works fine. i close and open the file, no errors, but the reset button is not loaded. any suggestions would be greatly appreciated!!!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
modifying code in run time
alfaista-did you get any notice of replies in your email that you shouldnt
have?--I have a notice of reply for this post as if I posted it? that kind of worries me--(security?) maybe you and I have similar email addresses-weird huh? "alfaista" wrote: i am sure there is an easier way to do this, and if so i'd sure like to know what it is!! in the meantime, i have an excel file that references a couple of add-ins. it has code that executes on the workbook events and on the worksheet events. (the code just calls code from the add-in). what i would like to be able to do is have to user save it as a "non-application-file" meaning that it won't have the links or code, so they can hand their files off to someone who does not have the application on their system and they may still view it without a bunch of errors. right now, if the user chooses to save the file that way, code excecutes that simply comments out the calls within the workbook. the trick is, when opening the workbook, i would like to check to see if the code is commented out, and if so place a "re-set" button on the menu so it can be re-set to its original form. the code i have to do this is as follows: Private Sub Workbook_Open() Dim lCount As Long Dim bReSet As Boolean Dim vFolderPath As Variant vFolderPath = QueryValue("Software\MyApp\DataLocation", "AddInPath") If IsEmpty(vFolderPath) Then Exit Sub End If lCount = ActiveWorkbook.VBProject.VBE.SelectedVBComponent.C odeModule.CountOfLines bReSet = ActiveWorkbook.VBProject.VBE.SelectedVBComponent.C odeModule.Find("' MyApp", 1, 1, lCount, 1) If bReSet Then ReSetButton MyAppWorkbook_Open End Sub problem #1, the code can not be protected or this does not work. big drawback. problem #2, this doesn't always work! if i run it from design mode, it works fine. i close and open the file, no errors, but the reset button is not loaded. any suggestions would be greatly appreciated!!!! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
modifying code in run time
no, no notification at all
"okeefe58" wrote: alfaista-did you get any notice of replies in your email that you shouldnt have?--I have a notice of reply for this post as if I posted it? that kind of worries me--(security?) maybe you and I have similar email addresses-weird huh? "alfaista" wrote: i am sure there is an easier way to do this, and if so i'd sure like to know what it is!! in the meantime, i have an excel file that references a couple of add-ins. it has code that executes on the workbook events and on the worksheet events. (the code just calls code from the add-in). what i would like to be able to do is have to user save it as a "non-application-file" meaning that it won't have the links or code, so they can hand their files off to someone who does not have the application on their system and they may still view it without a bunch of errors. right now, if the user chooses to save the file that way, code excecutes that simply comments out the calls within the workbook. the trick is, when opening the workbook, i would like to check to see if the code is commented out, and if so place a "re-set" button on the menu so it can be re-set to its original form. the code i have to do this is as follows: Private Sub Workbook_Open() Dim lCount As Long Dim bReSet As Boolean Dim vFolderPath As Variant vFolderPath = QueryValue("Software\MyApp\DataLocation", "AddInPath") If IsEmpty(vFolderPath) Then Exit Sub End If lCount = ActiveWorkbook.VBProject.VBE.SelectedVBComponent.C odeModule.CountOfLines bReSet = ActiveWorkbook.VBProject.VBE.SelectedVBComponent.C odeModule.Find("' MyApp", 1, 1, lCount, 1) If bReSet Then ReSetButton MyAppWorkbook_Open End Sub problem #1, the code can not be protected or this does not work. big drawback. problem #2, this doesn't always work! if i run it from design mode, it works fine. i close and open the file, no errors, but the reset button is not loaded. any suggestions would be greatly appreciated!!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help is needed for modifying this code. | Excel Programming | |||
modifying formulas with code | Excel Programming | |||
Modifying formulas through code | Excel Programming | |||
Need Help Modifying Code | Excel Programming | |||
Help modifying code | Excel Programming |