application.getopenfilename

YCJ

New Member
Joined
Feb 28, 2011
Messages
29
Hi there,

I'm stuck at this command at the moment.
Code:
Function GetFiles(sTitle As String) As Variant
    
    Dim sType As String
    Dim bMultiSelect As Boolean
    sType = "NF File, *.prn"
    bMultiSelect = True
    GetFiles = Application.GetOpenFilename(FileFilter:=sType, Title:=sTitle, MultiSelect:=bMultiSelect)
    
End Function
I got this to work on pc with windows xp and microsoft excel 2003, but it will not work on pc with windows 7 and excel 2007. Is it a problem with windows or microsoft?
I need it to work badly. Any advice would be much appreciated.

Thanks in advance,
CJ
 

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"
Hi and thanks for your reply

It prompts an error when it reaches getopenfilename.
Run-time error '1004':
Method 'GetOpenFilename' of object '_Application' failed

regards,
CJ
 
Upvote 0
I believe I am seeing the same problem. I have established that the GetOpenFilename with multiselect set to true is intermittently returning a string type instead of an array.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
I see this most often when multiple files are selected. I only rarely select a single file with my code, but have duplicated the error in that case as well. It does not matter if the files were selected by click and <ctrl> A or click and shift click. This problem comes and goes without an apparent rhyme or reason.<o:p></o:p>
If someone has some insight why GetOpenFilename fails in this manner we might be able to get to a solution.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,713
Members
452,939
Latest member
WCrawford

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