Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help is needed for modifying this code. J_J Excel Programming 2 October 10th 04 09:59 PM
modifying formulas with code Rick B[_6_] Excel Programming 3 January 28th 04 02:03 PM
Modifying formulas through code Rick B[_6_] Excel Programming 1 January 23rd 04 11:24 PM
Need Help Modifying Code JStone0218 Excel Programming 2 January 19th 04 10:27 AM
Help modifying code BruceJ[_2_] Excel Programming 1 December 10th 03 12:52 AM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"