首页 > 解决方案 > 除非应用程序关闭,否则链接文件不会关闭

问题描述

我有一个问题让我头疼了三天多,问题是我正在使用使用 vba 的数据输入应用程序,我已将其他一些 excel 工作簿链接到我的数据库条目,当我从我的应用程序的列表框:它们正常打开,但除非我关闭我的应用程序(并且所有 excel 工作簿都已关闭),否则它们不想关闭,如果有人可以帮助我,我将不胜感激。这是我的vba:

`Private Sub cmbfichedevie_Click()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Database")
Set shsearch = ThisWorkbook.Sheets("Searchdata")
Dim iRow As Long
Dim iRowsearchdat As Long
Dim ttt As Long

With shsearch
ttt = Selected_list + 1
iRowsearchdata = [Counta(Searchdata!A:A)]
If iRowsearchdata > 1 Then
    If Selected_list >= iRowsearchdata Or Selected_list = 0 Then
    MsgBox "Aucun élément n'est sélectionné.", vbOKOnly + vbInformation, "Ouvrir"
    Else
        If shsearch.Cells(ttt, 12) = "" Or shsearch.Cells(ttt, 12) = "No file" Then
        MsgBox "Il n'y a aucune fiche de vie pour cet article.", vbOKOnly + vbInformation, "Ouvrir"
        Else
        'shsearch.Cells(ttt, 12).Hyperlinks(1).Follow
        Workbooks.Open .Cells(ttt, 12)
        'Unload Me
        End If
    End If
    Exit Sub
Else
With sh
ttt = Selected_list + 1
iRow = [Counta(Database!A:A)]

If Selected_list >= iRow Or Selected_list = 0 Then
MsgBox "Aucun élément n'est sélectionné.", vbOKOnly + vbInformation, "Ouvrir"
Else

    If sh.Cells(ttt, 12) = "" Or sh.Cells(ttt, 12) = "No file" Then
    MsgBox "Il n'y a aucune fiche de vie pour cet article.", vbOKOnly + vbInformation, "Ouvrir"
    Else
    'sh.Cells(ttt, 12).Hyperlinks(1).Follow NewWindow:=True
    Workbooks.Open .Cells(ttt, 12)
    'Unload Me
    End If
End If
End With
End If
End With
End Sub

`

标签: excelvbahyperlinkuserform

解决方案


推荐阅读