Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Macro Won't Run in Excel 2003

The following code runs in Excel 2002 but not in Excel 2003.

We get the error: "Run Time Error '1004' Programmatic access to Visual Basic
Project is not trusted". It gets hung-up on the "For Each" line in the
following code:

Dim vbModule As Object
For Each vbModule In appWB.ActiveWorkbook.VBProject.VBComponents
If vbModule.Type = 1 Then ' "1" is a module
appWB.ActiveWorkbook.VBProject.VBComponents.Remove vbModule
End If
Next vbModule

We have checked the "Trust Access to Visual Basic Project" check box in the
ToolsMacroSecurityTrusted Sources tab (at the bottom), but to no avail.

Any Ideas?

A poster in this newsgroup suggested that we check the registry, but not
sure how to do this. Instruction in this area would be appreciated.

Thank you, Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Macro Won't Run in Excel 2003

Hi Mark,

Have you set a reference to the "Microsoft Visual Basic for
Applications Extensibility 5.3" with in the VBE? This you will need
when changing VBmodules etc within code.

James

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Macro Won't Run in Excel 2003

I have a glance at your macro. I think the "appWB" can be removed.
See the modified code below:

Dim vbModule As Object
For Each vbModule In ActiveWorkbook.VBProject.VBComponents
If vbModule.Type = 1 Then ' "1" is a module
ActiveWorkbook.VBProject.VBComponents.Remove vbModule
End If
Next vbModule

However, I would like to remind you that, your macro will potentially remove
the module in which the code resides...

Regards,
Edwin Tam

http://www.vonixx.com


"Mark" wrote:

The following code runs in Excel 2002 but not in Excel 2003.

We get the error: "Run Time Error '1004' Programmatic access to Visual Basic
Project is not trusted". It gets hung-up on the "For Each" line in the
following code:

Dim vbModule As Object
For Each vbModule In appWB.ActiveWorkbook.VBProject.VBComponents
If vbModule.Type = 1 Then ' "1" is a module
appWB.ActiveWorkbook.VBProject.VBComponents.Remove vbModule
End If
Next vbModule

We have checked the "Trust Access to Visual Basic Project" check box in the
ToolsMacroSecurityTrusted Sources tab (at the bottom), but to no avail.

Any Ideas?

A poster in this newsgroup suggested that we check the registry, but not
sure how to do this. Instruction in this area would be appreciated.

Thank you, Mark

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Macro Won't Run in Excel 2003

James -

It worked!!!! I was getting worried.

You know this reference was unchecked for Excel 2002 but the code to ran.
Very strange.

Thank you!!!!

Mark

" wrote:

Hi Mark,

Have you set a reference to the "Microsoft Visual Basic for
Applications Extensibility 5.3" with in the VBE? This you will need
when changing VBmodules etc within code.

James


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Macro Won't Run in Excel 2003

I can't explain excel 2002 but I know that I have had to check this
when adding/removing modules with in code. Glad to hear it was that
simple!

James

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
excel 2003 + macro help Neil Holden Excel Discussion (Misc queries) 2 March 17th 10 05:56 PM
Excel 2003 + macro Neil Holden Excel Discussion (Misc queries) 4 March 15th 10 12:35 PM
how to run acces 2003 macro in excell 2003 macro gonggo Excel Discussion (Misc queries) 0 October 6th 09 11:45 AM
Excel 2003 Macro Tanisha Excel Worksheet Functions 5 August 1st 06 09:31 PM
Excel 2003 macro Betina Andersen Excel Programming 0 December 2nd 04 07:28 AM


All times are GMT +1. The time now is 08:29 AM.

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

About Us

"It's about Microsoft Excel"