【发布时间】:2013-12-11 00:55:04
【问题描述】:
我正在尝试创建一个打开文件对话框的按钮,然后让您选择要复制到包含数据库的文件夹中的图像。我一直在使用这段代码,但我被困在 filecopy 命令上,我似乎无法正确格式化它。我使用数据库的路径加上几个文件夹,最后是一个组合框来选择特定的文件夹来创建路径(这样如果数据库被移动它就不会中断,并且组合框根据类别对图像进行排序) .这是我一直在使用的代码。谢谢各位。
Private Sub Command156_Click()
Dim fDialog As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim varFile As Variant
' Set up the File Dialog. '
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
fd.InitialFileName = [Application].[CurrentProject].[Path]
With fDialog
' Allow user to make multiple selections in dialog box '
.AllowMultiSelect = False
' Set the title of the dialog box. '
.Title = "Please select a Image"
' Clear out the current filters, and add our 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
filecopy([.SelectedItems],[GetDBPath] & "\Images\Equipment\" & Combo153)
Else
End If
End With
End Sub
【问题讨论】:
-
那么问题/你的问题是什么?
-
去掉括号
(、[和]。语法为FileCopy SourceFile, DestinationFile
标签: vba ms-access filedialog