Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tcb tcb is offline
external usenet poster
 
Posts: 3
Default Trust Access to Visual Basic Project

From VBA in Access an XLS workbook and sheets are created with command
buttons and code. If the user does not enable "Trust Access to Visual
Basic Project" the Access VBA traps an error and prompts the user to
enable the setting. (If there is a better way of doing this, please
advise.)

This scheme works, but it requires that all instances of the Excel.exe
be closed -- and the Access program from which the objects were
created. Unless Access is closed, it seems to still hold the value
that the security setting is not enabled. I would like to know how to
clear that.

After the Access program quits the user changes the security setting,
reopens the Access program, everything works just fine.

My goal would be to have the user prompted as is currently occurring,
but also make it so the Access program does not have to be closed and
reopened, and to have code that assures that all instances of the
excel.exe are closed.

This is the current scheme which works but is inadequate. If a user
does not have "Trust Access to Visual Basic Project" enabled an error
occurs he

Dim xlmodule1 As CodeModule
Set xlmodule1 =
objActiveWkb.VBProject.VBComponents(objActiveWkb.W orksheets(strFirstTabName).CodeName).CodeModule

With xlmodule1
StartLine = .CreateEventProc("Click", strButtonName) + 1
.InsertLines StartLine, "On Error Resume Next" & vbCrLf &
_
" Sheets(" & """" & strTabName & """" & ").Select"
& vbCrLf & _
"If Err < 0 Then" & vbCrLf & _
" MsgBox ""This is a cover sheet preview.""" &
vbCrLf & _
" End If" & vbCrLf
End With

The error is trapped he

Err_BuildCoverSheet:

If Err = 1004 Then

MsgBox "Trust Access to Visual Basic Project in Macro Security
Settings Must be Enabled", , "Enable Access to Visual Basic Project"

'''''''''''''''''''
Set xlmodule1 = Nothing
Set objActiveWkb = Nothing
Set objXL = Nothing

Excel.Application.Quit

'forces Access to quit he
Application.Quit acQuitPrompt

'''''''''''''''''''''''''''

Else

MsgBox Err.DESCRIPTION
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
Trust Access to Visual Basic Project - Access to Excel and back tcb Excel Programming 0 January 8th 08 02:43 AM
Trust access to visual basic project is grayed out [email protected] Excel Programming 3 September 22nd 06 04:07 PM
Trust Access to Visual Basic Project Farah[_7_] Excel Programming 0 November 7th 05 01:17 PM
Trust access to visual basic project in XP systems kasi Excel Discussion (Misc queries) 5 October 13th 05 01:32 PM
Trust access to visual basic project greyed out Amit Shanker Excel Discussion (Misc queries) 2 March 5th 05 09:41 PM


All times are GMT +1. The time now is 02:27 PM.

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"