Naming convention for workbook names

G

Guest

Can someone direct me to the naming convention for workbook names. What is
allowed and what is not? I want to suggest some workbook names for a SAVEAS
and want to avoid traps because of the convention.

Thanks,
Barb Reinhardt
 
C

Chip Pearson

If you avoid punctuation character other than a space or comma, you should
be OK. There are no special rules that apply to workbooks. A workbook name
must be a valid Windows file name, no more, no less. You could test with
code for a valid name before using it.

Function IsValidFileName(FileName As String) As Boolean
Dim S As String
On Error Resume Next
S = Dir(FileName)
IsValidFileName = (Err.Number = 0)
End Function

Sub AAA()
Dim FName As String
FName = "Bo|ok1.xls"
If IsValidFileName(FName) = True Then
Debug.Print "FileName Is Valid"
Else
Debug.Print "FileName is not valid."
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email on the web site)
 

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