【发布时间】:2016-11-30 13:43:57
【问题描述】:
我的代码在 2010 版 excel 中正常工作,但在 2013 版中不能。看看吧。
Sub select_strategy()
'Subroutine that lets the user select a strategy table
'
'Declare local variables
Dim strategyFileDialog As Office.FileDialog
'Declare local variables
Dim intStrategySelection As Integer
'Initialize global variables
Call initialize_global_variables
' Allows the user to select the strategy table to use
Set strategyFileDialog = Application.FileDialog(msoFileDialogFilePicker)
With strategyFileDialog
.Title = "Select Strategy Table"
.InitialFileName = ActiveWorkbook.Path
.AllowMultiSelect = False
End With
intStrategySelection = strategyFileDialog.Show 'updates cell only if a file is selected
If intStrategySelection <> 0 Then
wsMain.Cells(2, 3) = strategyFileDialog.SelectedItems(1)
Else
wsMain.Cells(2, 3) = ""
End If
End Sub
2013 版本的错误是编译错误:找不到项目或库。 任何想法如何解决它?
【问题讨论】:
-
要么切换到后期绑定,要么更改对 Microsoft Office 15.0 对象库的引用。
-
你能告诉我怎么做吗?可以写在代码里吗?
标签: vba