Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -- Hope that helps, Phil http://uk.geocities.com/philippeoget philippeoget at yahoo dot com Programming Excel: <a href="http://uk.geocities.com/philippeoget/xl/InternetLinkOrganiser.zip" target="_blank"The Excel A2Z Project: </a http://uk.geocities.com/philippeoget/a2z/ "p" wrote in message news:... Const MsgString As String = "Enter a name for this category:" & vbCrLf & vbCrLf _ & "Please make sure that the name does not exceed" & vbCrLf _ & "31 characters including spaces." & vbCrLf & vbCrLf _ & "Permitted word separators a" & vbCrLf _ & "Spaces [ ], Commas [ , ], Underscores [ _ ]," & vbCrLf _ & "Dashes [ - ] and Ampersands [ & ]." & vbCrLf & vbCrLf _ & "Make sure that the name does not contain any of the following characters:" & vbCrLf _ & "/ \ ? * [ ] ! =" _ If CheckName(NewTabName) = True Then MsgBox Prompt:=MsgString, _ Buttons:=vbCritical + vbOKOnly, _ title:="Help", _ HelpFile:=ThisWorkbook.Path & "\" & "Internet Links Organiser.chm", _ Context:=10004 Else '..... end if Function CheckName(ByVal NewSheetName As String) Dim NonValidChars(8), j Dim bFound As Boolean Dim pos NonValidChars(1) = "[" NonValidChars(2) = "]" NonValidChars(3) = "*" NonValidChars(4) = "/" NonValidChars(5) = "\" NonValidChars(6) = "?" NonValidChars(7) = "!" NonValidChars(8) = "=" For j = 1 To 8 If InStr(NewSheetName, NonValidChars(j)) 0 Then bFound = True End If Next j CheckName = bFound End Function "Tim" wrote in message ... Hi All, some help would be gratefully appreciated: i have written a small piece of vba to create a file name from a mixture of comboboxes (userform) and cells (worksheet), then saves the file (saveas). it works fine, but i want some automated way of making sure no 'illegal' characters are used in those 'boxes / cells (eg, ':' or '\'). is there a single instruction that looks for all such charatcers (that i could then use in a find-replace or if-then statement?). currently, it causes an error and stops the macro or if '\' occurs somewhere in the string, it results in an extra directory being formed (named from the contents to the left of the '\'), which is at best confusing! tia, tim |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Preventing Excel Product Piracy or Illegal Giveaways | Excel Discussion (Misc queries) | |||
want to remove all text characters equal to one character in length from text string | Excel Worksheet Functions | |||
want to remove all text characters equal to one character in length from text string | Excel Worksheet Functions | |||
preventing / converting 'illegal' characters in file-save text string | Excel Programming | |||
preventing input of illegal characters in an inputbox | Excel Programming |