0

In Excel2013 (32Bits) two FD.Show are called but one of them does not work. the file selection window does not show and proceed next statement directly. how to resolve this?

my example code)

Set FD = Application.FileDialog(msoFileDialogFilePicker)
With FD
   .Show

   If .SelectedItems.Count > 0 Then
      workbook1 = .SelectedItems(1)
   End If

   .Show
   If .SelectedItems.Count > 0 Then
      workbook2 = .SelectedItems(1)
   End If
End With
braX
  • 11,506
  • 5
  • 20
  • 33

1 Answers1

0

Quite straight forward answer, you are not able to execute 2nd FD call because you did not set end with in First FD call, it may throw error in my case, below is my solution for you, and work properly:

Set FD = Application.FileDialog(msoFileDialogFilePicker)

With FD
    .Show
        
    If .SelectedItems.Count > 0 Then
        workbook1 = .SelectedItems(1)
    End If
    
End With
    
With FD
    .Show
    
    If .SelectedItems.Count > 0 Then
        workbook2 = .SelectedItems(1)
    End If
    
End With
Kin Siang
  • 2,644
  • 2
  • 4
  • 8
  • thanks for your test and answer. in 64bit excel 2016, this works well but it does not works in 32bit excel 2013. – Myungsoo Jeong May 16 '21 at 01:42
  • Too bad, i don't have older version test for you, probably you can split the FD into 2 sub in order to make it sucessfully. – Kin Siang May 16 '21 at 02:32