Hidden File Extensions generating errors

N

Nick_F

Hi

I have a piece of code in Excel 2003 which at one point does this...

ActiveWorkbook.SaveCopyAs FileName:=XLSsaveStr
SetAttr (XLSsaveStr), vbNormal
Workbooks.Open (XLSsaveStr)
Workbooks(XLSsaveStrName).Activate

Where XLSsaveStrName could be "data.xls" and XLSsaveStr "C:/My data/
data.xls" however the last line generates an error if I change my
folder settings from view file extensions to hide extensions. That is
XLSsaveStrName must become simply "data". The code worked fine until I
distributed to another persons computer who has hidden file
extensions.

Is there a simple solution to the problem before I start attempting to
change XLSsaveStrName using on error and charcter functions? The
internet seemed surprisingly devoid of solutions to this problem when
it could cause drastic problems for people attempting to distribute
their code.

Cheers
Nick
 
N

NickHK

This works for me in W2K + Excel XP (can't say about Excel 2003), whatever
the value of that setting:

Const FILEPATHNAME As String = "C:\Test\Test.xls"

ActiveWorkbook.SaveCopyAs FILEPATHNAME
Workbooks.Open FILEPATHNAME

You may have problems with that setting when using the Windows collection,
but the Workbooks collection should not.

NickHK
 

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