opening order in msoFileDialogOpen

128 views Asked by At

I wrote a macro that asks me to open some files, and then it runs more macros depending on files' names.

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]

When the file dialog asks, I select three files while pressing and holding down the Ctrl button: montaggio.xls, pressa.xls, corpi.xls

I can select the pressa.xls as first file, or as the second one, or as the third one, but it always opens first. Why?

0

There are 0 answers