2017-04-04 79 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