我有将此后续编写的VBA代码转换为OpenOffice版本的任务。我尝试从OpenOffice启动它,但它不起作用(主要是"不满意的查询......"错误。我现在停留在Open File Dialog上,我可以使用VBA兼容打开文件我的对话现在看起来像那样(给出错误):
FileToOpen = Application.GetOpenFilename("Please choose a file to import", "Excel Files *.dbf (*.dbf)")
我也可以使用OpenOffice文件对话框,但无法找到相关信息。
提前致谢
答案 0 :(得分:1)
我对你的要求感到困惑,但如果你在创建文件对话框时遇到问题,那么这就是为你做的VBA代码。我认为这就是你所要求的,但我可能是错的。
Private Sub cmdFileDialog_Click()
' This requires a reference to the Microsoft Office 11.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
' Clear the list box contents.
Me.FileList.Value = ""
' Set up the File dialog box.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Change allowmultiselect to true if you want them to be able to select multiple files
.AllowMultiSelect = False
' Set the title of the dialog box.
.Title = "Select One or More Files"
' Clear out the current filters, and then add your own.
.Filters.Clear
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
' Loop through each file that is selected and then add it to the list box.
For Each varFile In .SelectedItems
Me.FileList.Value = varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub