?
Solved

Replace invalid characters in filename

Posted on 2006-05-24
2
Medium Priority
?
1,135 Views
Last Modified: 2008-02-01
Hello All,

Can somebody please provide me some code which would enable me to replace all invalid characters in a filename which I would like to save. For example the string given to the function may be

"Information about butter/hooks" but the output should be:

"Information about butter_hooks"

But obviously this could happen with any of the following symbols:

\ / : * ? < > |

Can somebody help me? I am using VB6 / VBA. Thanks

0
Comment
Question by:butterhook
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 16749833
Not sure what difficulty you are having, but here is some code:

Const InvalidChars = "\ / : * ? < > |"
dim i as integer
for i = 1 to len(InvalidChars)
    strFileName = Replace(strFileName, Mid$(InvalidChars, i, 1), "_")
Next i
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 16749848
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question