Simple use of Len?

S

Stuart

vFileName holds the full path and filename of a Word
document opened via Excel VBA.

A new workbook is created, and data is imported from
the Word document.

Before I save the new workbook, how can I use LEN
to simply change vFileName to end as *.xls, rather
than its' current *.doc, please?

Regards.
 
S

Stuart

That is very handy to know !
Many thanks.

Would a 'Len' solution be backwards-compatible
with my users? Their earliest version is Excel'97.

Regards.
 
T

Tom Ogilvy

sFileName = application.substitute(sfilename, "doc", "xls")


or

sfilename = Left(sfilename,len(sFilename)-4) & ".xls"

should work in all versions of Excel that support VBA.
 

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