我需要这个VBA宏,它允许用户从他们自己的文件夹中选择PDF文件,然后宏应该将PDF复制到固定的文件夹目标并根据在ComboBoxes中选择两个值。VBA复制和重命名用户在对话框中选择的文件
我已经尝试了下面的代码,但在最后一句失败。任何人都可以帮助我?
Sub add_testrepport()
Dim intChoice As Integer
Dim strPath As String
'allow the user to select one file
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
'make the file dialog visible to the user
intChoice = Application.FileDialog(msoFileDialogOpen).Show
'determine what choice the user made
If intChoice <> 0 Then
'get the file path selected by the user
strPath = Application.FileDialog(_
msoFileDialogOpen).SelectedItems(1)
'copy the file path to filecopy
FileCopy strPath, "K:\05_RAP\Klement\Test"
End If
End Sub
虽然搜索了很多,你找到了什么代码?你尝试过吗?发生了什么? –