我需要這個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
雖然搜索了很多,你找到了什麼代碼?你嘗試過嗎?發生了什麼? –