Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Can code delete code

Hello, can any of the following be done, and if so, can you please give an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Can code delete code

Steph,

See www.cpearson.com/excel/vbe.htm for details and example code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you
please give an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Can code delete code

Everything you wanted to know about programming to the VBE...

http://www.cpearson.com/excel/vbe.htm
--
HTH...

Jim Thomlinson


"Steph" wrote:

Hello, can any of the following be done, and if so, can you please give an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Can code delete code

Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you please give an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Can code delete code

Thanks "Guy" would be more appropriate. I just pointed you to Chips site.
That being said I should hit Chip up for a referal fee. I send people to his
site a lot...

;-)
--
HTH...

Jim Thomlinson


"Steph" wrote:

Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you please give an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Can code delete code

Can I ask a follow-up question? From Chip's site, I learned that the VBA
Extensibility library reference must be set, along with the Trust access to
VB project check box. Can these be "set" programatically?

"Steph" wrote in message
...
Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you please give

an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Can code delete code

Trusted sources is a security setting so that is a big fat no...

Extensibility is a reference so there is no need to use code to add the
reference via code. The only time you would need this would be if the code
that your code is writing requires a reference to an external library. Is
that your question?
--
HTH...

Jim Thomlinson


"Steph" wrote:

Can I ask a follow-up question? From Chip's site, I learned that the VBA
Extensibility library reference must be set, along with the Trust access to
VB project check box. Can these be "set" programatically?

"Steph" wrote in message
...
Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you please give

an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Can code delete code

Basically I am writing code that others will be using. So I didn't want it
to error out if the user didn't have the appropriate security settings and
references set.

"Jim Thomlinson" wrote in message
...
Trusted sources is a security setting so that is a big fat no...

Extensibility is a reference so there is no need to use code to add the
reference via code. The only time you would need this would be if the code
that your code is writing requires a reference to an external library. Is
that your question?
--
HTH...

Jim Thomlinson


"Steph" wrote:

Can I ask a follow-up question? From Chip's site, I learned that the

VBA
Extensibility library reference must be set, along with the Trust access

to
VB project check box. Can these be "set" programatically?

"Steph" wrote in message
...
Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you please

give
an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!









  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Can code delete code

Steph,

You can get around the requirement that the Extensibility library
be set. Declare the VBIDE variables As Object, and replace the
constants that begin with vbext_ with their actual numeric
values.

You can programmatically add a reference to the Extensibility
library with code like


Dim Ref As Object
On Error Resume Next
Err.Clear
Set Ref = ActiveWorkbook.VBProject.References("VBIDE")
If Ref Is Nothing Then
ActiveWorkbook.VBProject.References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
Major:=5, Minor:=3
End If


You cannot programmatically change the "Trust Access To
VBProject" setting. This must be done manually.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steph" wrote in message
...
Can I ask a follow-up question? From Chip's site, I learned
that the VBA
Extensibility library reference must be set, along with the
Trust access to
VB project check box. Can these be "set" programatically?

"Steph" wrote in message
...
Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you
please give

an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!








  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Can code delete code

Great. Thanks so much Chip.

"Chip Pearson" wrote in message
...
Steph,

You can get around the requirement that the Extensibility library
be set. Declare the VBIDE variables As Object, and replace the
constants that begin with vbext_ with their actual numeric
values.

You can programmatically add a reference to the Extensibility
library with code like


Dim Ref As Object
On Error Resume Next
Err.Clear
Set Ref = ActiveWorkbook.VBProject.References("VBIDE")
If Ref Is Nothing Then
ActiveWorkbook.VBProject.References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
Major:=5, Minor:=3
End If


You cannot programmatically change the "Trust Access To
VBProject" setting. This must be done manually.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steph" wrote in message
...
Can I ask a follow-up question? From Chip's site, I learned
that the VBA
Extensibility library reference must be set, along with the
Trust access to
VB project check box. Can these be "set" programatically?

"Steph" wrote in message
...
Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you
please give

an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!












  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Can code delete code

Chip,
One more question - can I test prior to runtime whether or not the trusted
source box is checked, and if not prompt a msgbox?

"Chip Pearson" wrote in message
...
Steph,

You can get around the requirement that the Extensibility library
be set. Declare the VBIDE variables As Object, and replace the
constants that begin with vbext_ with their actual numeric
values.

You can programmatically add a reference to the Extensibility
library with code like


Dim Ref As Object
On Error Resume Next
Err.Clear
Set Ref = ActiveWorkbook.VBProject.References("VBIDE")
If Ref Is Nothing Then
ActiveWorkbook.VBProject.References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
Major:=5, Minor:=3
End If


You cannot programmatically change the "Trust Access To
VBProject" setting. This must be done manually.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steph" wrote in message
...
Can I ask a follow-up question? From Chip's site, I learned
that the VBA
Extensibility library reference must be set, along with the
Trust access to
VB project check box. Can these be "set" programatically?

"Steph" wrote in message
...
Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can you
please give

an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!










  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Can code delete code

Steph,

The following code will test whether access to the VBProject is
enabled.

Dim Ref As Object
On Error Resume Next
Set Ref = ThisWorkbook.VBProject.References("Excel")
If Ref Is Nothing Then
Debug.Print "No trust"
Else
Debug.Print "trust"
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steph" wrote in message
...
Chip,
One more question - can I test prior to runtime whether or not
the trusted
source box is checked, and if not prompt a msgbox?

"Chip Pearson" wrote in message
...
Steph,

You can get around the requirement that the Extensibility
library
be set. Declare the VBIDE variables As Object, and replace the
constants that begin with vbext_ with their actual numeric
values.

You can programmatically add a reference to the Extensibility
library with code like


Dim Ref As Object
On Error Resume Next
Err.Clear
Set Ref = ActiveWorkbook.VBProject.References("VBIDE")
If Ref Is Nothing Then
ActiveWorkbook.VBProject.References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
Major:=5, Minor:=3
End If


You cannot programmatically change the "Trust Access To
VBProject" setting. This must be done manually.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steph" wrote in message
...
Can I ask a follow-up question? From Chip's site, I learned
that the VBA
Extensibility library reference must be set, along with the
Trust access to
VB project check box. Can these be "set" programatically?

"Steph" wrote in message
...
Thanks guys!

"Steph" wrote in message
...
Hello, can any of the following be done, and if so, can
you
please give
an
example of syntax? Thanks!

1. Can code delete an open event procedure?
2. Can code delete an entire module?
3. Can code delete specific lines within a module?
4. CAn code delete an entire sub() within a module?

Thanks again!












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
Delete code chrisnsmith Excel Discussion (Misc queries) 4 March 8th 09 01:10 AM
Code to delete a Line in a another code helmekki[_88_] Excel Programming 1 August 8th 05 01:14 AM
Delete Shortcut with Code zSplash Excel Programming 9 April 10th 04 06:55 PM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM
VBA code to delete VBA code in another Workbook Chip Pearson Excel Programming 0 September 15th 03 03:54 PM


All times are GMT +1. The time now is 06:04 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"