programmatic access to visual basic project is not trusted

R

Rob Kings

Hi

I've got some VB code that uses OLE automation to do some stuff in Excel.
I've started getting the error "programmatic access to visual basic project
is not trusted" but I DO have the setting "Trust Access to Visual Basic
Project" enabled.

Interesting points to note:

1. This code has been working (certainly it was last week)

2. If I run my routine from inside Excel then its OK

3. Because of some other problems (A Microsoft security update breaking
something) I had to go back to a restore point. When I then went to
Microsoft update (to prevent the same download happening again) I got 148Mb
of stuff which included lots of Office 2003 "fixes". Is it possible that
they broke something else?

Any ideas?
 
R

Rob Kings

Oh buggrit buggrit buggrit. Found it.

I instantiate Excel using

Set oExcel = CreateObject("Excel.application")

So that I don't have to worry about the version of the target machines. For
some reason this is instantiating Excel 2002 which DIDN'T have "Trust
Access to Visual Basic Project" enabled.

Now, since I have 2003 installed, how come OLE is running 2002?

Rob
 
D

Dave Peterson

I don't know.

And I don't know if this will work, but it'll give you something to do until
someone smart comes along.

If you have multiple versions of excel on the same pc (I don't), then the
version that should be used when you double click on a .xls file (in windows
explorer) should be the last one installed (or the last one registered).

So I'd try this:
close all running instances of excel
windows start button|Run
c:\path\to\excel2003.exe /unregserver
followed by
c:\path\to\excel2003.exe /regserver

If it works, post back and the smart person coming along later won't waste
his/her time.

If it doesn't work, post back and maybe that smart person will help.
 
R

Rob Kings

Dave

Many thanks for that. What I didn't realise until later last night (before I
read your post) was that the version you get when you double-click an XLS
was also 2002. (I tend to switch between double-clicking the files and using
the Quick-Launch toolbar to explicitly launch 2003) I suppose it says a lot
about either me, or just how inconsequential the differences are between
2002 and 2003, that I couldn't spot them !

I'd also looked in the registry at
HKEY_CLASSES_ROOT\Excel.Application\CurVer which is set to
Excel.Application.10 on my machine. I tried setting this to
Excel.Application.11 but it didn't make any difference (so I set it back to
10)

Anyhow, what I did was slightly different to what you wrote.

1. I did an /unregserver on the 2002 version

2. I then tried double-clicking a file and still got 2002

3. I did a /regserver on the 2003 version. This gave me a progress-bar
something like "Please wait whilst Windows checks Office 2003" or something.

After that SUCCESS. Both double-clicking, and OLE bring up 2003

Many many thanks

Rob
 
D

Dave Peterson

Glad you got it working.

Rob said:
Dave

Many thanks for that. What I didn't realise until later last night (before I
read your post) was that the version you get when you double-click an XLS
was also 2002. (I tend to switch between double-clicking the files and using
the Quick-Launch toolbar to explicitly launch 2003) I suppose it says a lot
about either me, or just how inconsequential the differences are between
2002 and 2003, that I couldn't spot them !

I'd also looked in the registry at
HKEY_CLASSES_ROOT\Excel.Application\CurVer which is set to
Excel.Application.10 on my machine. I tried setting this to
Excel.Application.11 but it didn't make any difference (so I set it back to
10)

Anyhow, what I did was slightly different to what you wrote.

1. I did an /unregserver on the 2002 version

2. I then tried double-clicking a file and still got 2002

3. I did a /regserver on the 2003 version. This gave me a progress-bar
something like "Please wait whilst Windows checks Office 2003" or something.

After that SUCCESS. Both double-clicking, and OLE bring up 2003

Many many thanks

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top