从 Excel 启动时使 Access 背景不可见

Make Access background be invisible when launching it from Excel

我用过这个code for hiding the Access window to show only popup forms

这是Access的Load事件"Display Form"

Private Sub Form_Load()
    Me.Visible = True
    fSetAccessWindow (SW_HIDE)
    DoCmd.GoToRecord , , acNewRec
End Sub

这会在我直接启动 Access 时正确地隐藏背景。

在正常使用中,我想通过 Excel 命令按钮(下面的代码)调用 Access。表单加载,但 Access window 在以这种方式启动时仍然可见。

谁能看出行为不同的原因?

谢谢

Sub Clicked_Edit()
    Application.ScreenUpdating = False

    Dim ac As Object
    Dim str As String

    On Error Resume Next
    Set ac = GetObject(, "Access.Application")
    If ac Is Nothing Then
        Set ac = GetObject("", "Access.Application")
        ac.OpenCurrentDatabase 
       "<MyFilePathToDatabase>"
    End If
    AppActivate "Microsoft Access"

    Application.ScreenUpdating = True
End Sub

您可以将 Application.Visible 属性 设置为 false ac.Visible = False