File Dialog Excel 2013 Error

cddcdc

New Member
Joined
Oct 23, 2017
Messages
1
Hi,

I have the below code that is working for most of my users but is crashing in the red line for some of the users. The only common trend I've found for those that this is not working is that they are Excel 2013 users as everyone else is Excel 2010. The Excel 2013 users have a run-time error 1004: "Method Open of object Workbooks failed". I honestly don't have a clue of what's making this error show up only for these users. Could you please try to help me?

Many thanks!

Code:
[COLOR=#333333]Dim SoH As Workbook
Dim Sheet As Worksheet
Dim filedialog1 As FileDialog
Dim dialogtitle As String
Dim chosenfile As String

MsgBox "Choose the most recent report.", vbExclamation

dialogtitle = "Choose the most recent report."

Set filedialog1 = Application.FileDialog(msoFileDialogFilePicker)

With filedialog1
    .InitialFileName = "\\Ukpshnsnp001a\"
    .AllowMultiSelect = False
    .Filters.Clear
    .Title = dialogtitle

    If filedialog1.Show = False Then
        MsgBox "No file was selected. Please try again.", vbCritical, "Erro"
        Exit Sub
    End If
    
    chosenfile = .SelectedItems(1)
    
End With

[/COLOR][COLOR=#b22222][B]Set SoH = Workbooks.Open(Filename:=chosenfile)[/B][/COLOR][COLOR=#333333]
Set Sheet = SoH.Worksheets("Sheet1")[/COLOR]
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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