View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
kounoike[_2_] kounoike[_2_] is offline
external usenet poster
 
Posts: 126
Default Invalid Characters in Worksheet Name (International)

I'm sorry, but i'm quite unfamiliar with C# and don't have C#. so, i have no
idea about narrowing in C#.
i'm not sure, but the document below, thought, it is .NET, might be a help
for you.

http://msdn2.microsoft.com/en-US/lib...s.strconv.aspx

keizi

"Drew Lettington" wrote in
message ...
It sounds like you are on the right track. Narrowing the wide character
and
checking for path separator is probably the right way to go.

Since my code is not VB, do you know how to do the equivalent character
narrowing in C#?

"kounoike" wrote:

Thank you for your explanation. As your explanation, a yen character (¥)
(i
call this wide yen) and the path separator
character(i call this narrow yen) are not same in Japanese version. but
in
Japanese version the test under returns "match"

Sub Test()
If Application.PathSeparator = StrConv("¥", vbNarrow) Then
MsgBox "match"
Else
MsgBox "not match"
End If
End Sub

so, as for yen character, something like - Replace(StrConv(somesheetname,
vbNarrow), Application.PathSeparator , "_")
will replace yen characters (¥) in somesheetname with underscore (_)
in
"Japanese version".

keizi

"Drew Lettington" wrote in
message ...
Thank you for the post. The code you included is very similar to my
first
attempt to solve this problem. But what I found was that the separator
character is backslash (\) even though it displays as yen on my
Japanese
system. So, if the proposed worksheet name contains backslash then the
code
replaces it with underscore (_) and the name is good. However, if the
proposed name contains a yen character (¥) then it doesn't get
replaced
and
the name is invalid.

I could modify my code to explicitly check for yen character; Japanese
would
work and English would not be impacted in most cases. But there are
other
international versions of Excel and if I want my code to work in all of
them
I need to know what characters they won't accept.

I thought about disallowing currency symbol but dollar ($) is valid in
English Excel. Plus, without knowing what Excel will allow and
disallow
all
bases may still not be covered.

By the way, here's a macro you can run to see if separator and yen are
not
the same character:

Sub Test()
If Application.PathSeparator < "¥" Then
MsgBox "Separator (" + Application.PathSeparator + ") and yen
(¥)
are not the same character"
End If
End Sub

"kounoike" wrote:

I'm using Japanese Version, and not having English version. so, i'm
not
sure
whether the code of yen character is some or not in both version. but
somthing like this seems to work for me in my Japanese version, though
i
think StrConv(nm, vbNarrow) is not valid in English version.

Function makeshname(ByVal nm As String)
Dim nlist
Dim i As Long
nlist = Array(" ", "[", "]", ":", "*", "/", "?",
Application.PathSeparator)
For i = 0 To UBound(nlist)
nm = Replace(StrConv(nm, vbNarrow), nlist(i), "_")
Next
makeshname = nm
End Function

keizi

"Drew Lettington" wrote in
message ...
That was my first attempt to fix the problem but path separator is
actually
'\' on the Japanese system; it just displays as yen. And Japanese
Excel
doesn't allow either backslash or yen characters in worksheet names.

Also I'm pretty sure that the invalid characters are 'built-in' to
Excel.
That is, yen character would be invalid in Japanese Excel even if it
was
running on an English system.

- Drew

"kounoike" wrote:

How about using Application.PathSeparator? This indicates ¥character
in
the
Japanese environment.

keizi