xl2k vs xl03 code difference

C

CLR

Hi All.......the following code works fine in xl03 but does not work in xl2k.
Can anyone please tell me if it can be modified to work in xl2k?

Dim strFile As Variant
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xls"
.InitialFileName = ThisWorkbook.Path & "\"
.Show
strFile = .SelectedItems(1)
End With

Workbooks.Open Filename:=strFile

TIA
Vaya con Dios,
Chuck, CABGx3
 
J

Jan Karel Pieterse

Hi Clr,
Hi All.......the following code works fine in xl03 but does not work in xl2k.
Can anyone please tell me if it can be modified to work in xl2k?

I think the FileDialog thingy was introduced with Excel XP.

You can use something like this on any Excel version as of '97:

Sub GetOpenFileNameExample()
Dim lCount As Long
Dim vFilename As Variant
Dim sPath As String
Dim lFilecount As Long
sPath = "c:\windows\temp\"
ChDrive sPath
ChDir sPath
vFilename = Application.GetOpenFilename( _
"Microsoft Excel files (*.xls),*.xls", , _
"Please select the file(s) to open", , False)
If TypeName(vFilename) = "Boolean" Then Exit Sub
Workbooks.Open cstr(vFilename)
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com
 
C

CLR

Thanks Jan Karel, I appreciate that very much.
I'll give it a try ASAP.

Vaya con Dios,
Chuck, CABGx3
 
C

CLR

Outstanding........works super-fine for me

Many thanks Jan Karel

Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top