PC Review


Reply
Thread Tools Rate Thread

Difficulty opening Access from within Excel

 
 
Mary S.
Guest
Posts: n/a
 
      25th Feb 2009
I am trying to open an Access database from within Excel using VBA. Here is
my code:

Dim MyAccess As Access.Application
Set MyAccess = CreateObject("Access.Application")
MyAccess.Visible = True
MyAccess.OpenCurrentDatabase ("\\server\folder\xyz.mdb")

The last line of code triggers the following error message:

Run-time error '7866'
Microsoft Office Access can't open the database because it is missing, or
opened exclusively by another user.

The database is not, in fact, opened exclusively by another user. The error
message appears when the Access macro security level is set to medium. The
error message does not appear when the Access macro security level is set to
low. Is there any way to avoid this error, or bypass the error and still
open the database, without changing the Access macro security level to low?
Thanks,
--
Mary S.
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      25th Feb 2009
Try this

MyAccess.AutomationSecurity = msoautomationsecurityLow
MyAccess.OpenCurrentDatabase ("\\server\folder\xyz.mdb")
MyAccess.AutomationSecurity = msoautomationsecuritybyUI

(I think that's it)


"Mary S." wrote:

> I am trying to open an Access database from within Excel using VBA. Here is
> my code:
>
> Dim MyAccess As Access.Application
> Set MyAccess = CreateObject("Access.Application")
> MyAccess.Visible = True
> MyAccess.OpenCurrentDatabase ("\\server\folder\xyz.mdb")
>
> The last line of code triggers the following error message:
>
> Run-time error '7866'
> Microsoft Office Access can't open the database because it is missing, or
> opened exclusively by another user.
>
> The database is not, in fact, opened exclusively by another user. The error
> message appears when the Access macro security level is set to medium. The
> error message does not appear when the Access macro security level is set to
> low. Is there any way to avoid this error, or bypass the error and still
> open the database, without changing the Access macro security level to low?
> Thanks,
> --
> Mary S.

 
Reply With Quote
 
Mary S.
Guest
Posts: n/a
 
      3rd Mar 2009
Barb,

Thanks for your reply. I tried the code you suggested below, but I'm still
getting the same error message. I think the problem is that unsafe
expressions are not blocked. Whenever I have the macro security level in
Access set to medium and I open a database, I get the message: Security
Warning: Unsafe expressions are not blocked. Do you want to block unsafe
expressions? [Yes] [No] [Help]. If I click [Yes], I get another message:
Microsoft Access cannot change the registry setting that controls whether or
not unsafe expressions are blocked. Your account is not authorized to change
this registry setting. To change this setting, contact your system
administrator. [OK] [Help]

The code you suggested does work if the macro security level in Access is
set to medium and unsafe expressions are blocked. However, on the network
where these files exist, users typically do not have administrator privileges
on the computers they are using. Also, the default setting seems to be to
not block unsafe expressions, and thus the typical user will see this message
(and will be unable to change whether unsafe expressions are blocked). I
believe that for the typical user to successfully run this Excel macro he/she
would have to manually set the Access macro security level to low. The code
you suggested does not allow the Access database to open if unsafe
expressions are not blocked.

Can anyone think of a way to bypass this? Please respond with any ideas you
may have. If it is not possible, I'm going to change my approach and put my
VBA code into the Access database and have it generate the Excel file that I
want to create.

Thanks,
--
Mary S.


"Barb Reinhardt" wrote:

> Try this
>
> MyAccess.AutomationSecurity = msoautomationsecurityLow
> MyAccess.OpenCurrentDatabase ("\\server\folder\xyz.mdb")
> MyAccess.AutomationSecurity = msoautomationsecuritybyUI
>
> (I think that's it)
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difficulty opening files with Excel Sandy5590 Microsoft Excel Misc 0 15th Mar 2010 04:07 PM
Difficulty opening excel files through Windows Explorer =?Utf-8?B?U3B1ZGxvdmVy?= Microsoft Excel Crashes 2 22nd Apr 2006 11:31 AM
Difficulty in opening a couple of established Excel 97 files =?Utf-8?B?bGtwcmluZ2xl?= Microsoft Frontpage 3 10th Aug 2005 08:10 PM
Opening Excel Application difficulty =?Utf-8?B?QXJpc3Rvbg==?= Microsoft Excel Misc 1 20th Feb 2005 01:16 AM
Difficulty Importing Excel to Access Sean Microsoft Access External Data 2 15th Jun 2004 02:14 AM


Features
 

Advertising
 

Newsgroups
 


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