在msoFileDialogOpen中打开订单

时间:2015-06-24 14:00:23

标签: excel vba filedialog

我写了一个宏,要求我打开一些文件,然后根据文件的名称运行更多的宏。

With Application.FileDialog(msoFileDialogOpen)
.ButtonName = "Seleziona"
.InitialView = msoFileDialogViewList
.AllowMultiSelect = True
.Filters.Add "File Excel", "*.xls", 1
.InitialFileName = "\\SERVER-PDC\Archivi\DOCUMENTI SU SERVER\LAURA\"
.Title = "Seleziona i file: corpi, mancanti, montaggio, pressa. Questa è la settimana numero " & Format(Date, "ww")
.Show
On Error GoTo Erroremultiselezione
     For Each vrtSelectedItem In .SelectedItems
        Workbooks.Open Filename:=vrtSelectedItem, CorruptLoad:=xlRepairFile
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:=vrtSelectedItem, FileFormat:=xlExcel8
        If Left(ActiveWorkbook.Name, 5) = "monta" Then
            Application.Run "pacchetto_rev7.xls!Montaggio"
        ElseIf Left(ActiveWorkbook.Name, 5) = "corpi" Then
            Application.Run "pacchetto_rev7.xls!Corpi"
        ElseIf Left(ActiveWorkbook.Name, 5) = "press" Then
            Application.Run "pacchetto_rev7.xls!Pressacoll"
        ElseIf Left(ActiveWorkbook.Name, 5) = "manca" Then
            Application.Run "pacchetto_rev7.xls!Missing"
        Else: GoTo Erroremultiselezione
        End If
    Next vrtSelectedItem
End With  
[more code follows]

当文件对话框询问时,我按住Ctrl键的同时选择三个文件:montaggio.xls,pressa.xls,corpi.xls

我可以选择pressa.xls作为第一个文件,或者作为第二个文件,或者作为第三个文件,但它总是先打开。为什么?

0 个答案:

没有答案