2017-04-04 41 views
0

我有一個訪問數據庫,在Windows 7 Office 2010下工作正常,但在Windows 10 Office 2013中,它的一個代碼不工作。訪問VBA GetOpenFileName不工作

這裏是有問題的代碼。

Private Sub Text0_Click() 
Dim s As String 
s = MyGetOpenFileName 
Me.Text0.Value = s 

末次

在Windows 7中當過我單擊文本框的窗戶打開。但在Windows 10中,如果我點擊沒有任何反應。

回答

1

我認爲這應該工作:

昏暗的OpenFile作爲工作簿

fPath = Application.GetOpenFilename(FileFilter:="Excel files, *.xl; *.xlsx; *.xlsm; *.xlsb; *.xlam; *.xltx; *.xls; *.xlt ", Title:="You can type the title for Your window here") 

If fPath = False Then 
    Exit Sub 
End If 

Set OpenedFile = Workbooks.Open(fileName:=fPath, UpdateLinks:=0, IgnoreReadOnlyRecommended:=True) 

我顯示出與過濾器窗口Excel文件,然後檢查是否屬實,然後我打開文件文件入圍。

+0

對不起,這段代碼給我一個編譯器錯誤(用戶定義類型沒有定義) – Riufaan

+0

好吧,我已經看到你的問題與Excel的關係,所以我的代碼是Excel的VBA。我認爲對於訪問數據庫可能會有所幫助,這個主題:http://stackoverflow.com/questions/1091484/how-to-show-open-file-dialog-in-access-2007-vba – Mikisz