AW: Sicherheitsmeldung beim Zugriff auf Access
13.04.2008 13:52:26
Reinhard
Hi Tino,
ich habe leider von Access noch weniger Ahnung als von Excel, und das ist schon schwierig :-)
Ich bin mir auch nicht völlig sicher ob dir das weiterhilft, zumindest wird da wohl das Starten der Autoexec unterdrückt, ob damit deine Sicherheitswarnung auch nicht mehr kommt kann ich nur erahnen.
Abgesehen davon verstehe ich gar nicht warum man da so einen aufwendigen Code für braucht...
Und sowieso und überhaupt wo die ganzen Makros sind die da mit Call aufgerufen werden :-(
Vielleicht habe ich da in dem Link was übersehen.
Egal, schau halt mal.
Wenn es dir nicht weiterhilft, setze halt die Frage auf noch offen.
Function fGetRefNoAutoexec(ByVal strMDBPath As String) As Access.Application
On Error GoTo ErrHandler
Dim objAcc As Access.Application
Dim TIdSrc As Long, TIdDest As Long
Dim abytCodesSrc(0 To 255) As Byte
Dim abytCodesDest(0 To 255) As Byte
If (Len(Dir$(strMDBPath, vbNormal)) = 0) Then Err.Raise 53
Set objAcc = New Access.Application
With objAcc
.Visible = True
TIdSrc = GetWindowThreadProcessId(Application.hWndAccessApp, ByVal 0)
TIdDest = GetWindowThreadProcessId(.hWndAccessApp, ByVal 0)
If CBool(AttachThreadInput(TIdSrc, TIdDest, True)) Then
Call SetForegroundWindow(.hWndAccessApp)
Call SetFocusAPI(.hWndAccessApp)
Call GetKeyboardState(abytCodesSrc(0))
Call GetKeyboardState(abytCodesDest(0))
abytCodesDest(VK_SHIFT) = 128
Call SetKeyboardState(abytCodesDest(0))
Call .OpenCurrentDatabase(strMDBPath, False)
Call SetKeyboardState(abytCodesSrc(0))
End If
' release
Call AttachThreadInput(TIdSrc, TIdDest, False)
Call SetForegroundWindow(Application.hWndAccessApp)
Call SetFocusAPI(Application.hWndAccessApp)
End With
Set fGetRefNoAutoexec = objAcc
Set objAcc = Nothing
Exit Function
ErrHandler:
If (TIdDest) Then Call AttachThreadInput(TIdSrc, TIdDest, False)
Call SetForegroundWindow(Application.hWndAccessApp)
With Err
.Raise .Number, .Source, .Description, .HelpFile, .HelpContext
End With
End Function
Code:
Dim objAppAccess As Access.Application
Set objAppAccess = CreateObject("Access.Application")
Set objAppAccess = fGetRefNoAutoexec("deine.mdb")
' deine zugriffe ...
objAppAccess.DBEngine.Workspaces(0).Databases(0).Containers(5).Documents.Count
'dont forget to ...
objAppAccess.CloseCurrentDatabase
objAppAccess.Quit
Quelle: http://www.office-loesung.de/ftopic30657_0_0_asc.php
Gruß
Reinhard