fileDialog.show does not show a window

RamaG

New Member
Joined
Jan 19, 2017
Messages
5
I am trying to choose a file to open later. This piece of my code used to work until a few days ago and is supposed to show the file dialog box. What happens now is that the dialog box does not show and returns 0 (cancel).

I have MS Office Pro Plus 2010 Excel version 14.07
Code:
Sub debugFileDialog()
Dim fd As FileDialog
Set fd = Nothing
    Set fd = Application.FileDialog(msoFileDialogOpen)
    If fd Is Nothing Then
        MsgBox ("problem with fd in nextStudentFileOpen")
        Exit Sub
    End If
    fd.InitialFileName = localPath
    fd.Title = "Select the file"
    If fd.Show = 0 Then 'user has cancelled

         'do nothing and skip this student
        MsgBox ("skipping")
      
    Else
             MsgBox ("Processing")
    End If 'student processing
    Set fd = Nothing
         
 End Sub
I use this feature multiple times a day for work, so any help is much appreciated.

Rama
 
Last edited by a moderator:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
There is no need to set fd to Nothing before assigning it nor do you need that assignment at the end of the routine; the local variable will be automatically release when leaving the subroutine. When I tried a version of your routine on my computer, it seems to work fine; I just had to change localPath to something on my machine.

Sometimes some of the application links get messed up in the registry. To fix this, shutdown Excel, go to Windows Control Panel -Programs and Features (depending on your version of Windows). Find MS-Office and select it then click on Change (or something like it, but not Uninstall). When the dialog comes up, click on Repair and Ok. Wait a few minutes and try again. This will often fix the registry errors and a few other things.
 
Last edited:
Upvote 0
Thank you for responding to my question. You were right about it being some sort of system problem. I didn't even have to go into the control panel, just shutting down and restarting did the trick.

Maybe leaving Excel open 24/7 with multiple windows and other applications is not such a great idea after all :stickouttounge:
 
Upvote 0

Forum statistics

Threads
1,223,964
Messages
6,175,658
Members
452,664
Latest member
alpserbetli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top