+ Reply to Thread
Results 1 to 5 of 5

creation of directory fails due to invalid characters

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    creation of directory fails due to invalid characters

    Hi,

    I have made a macro, which puts files into a directory. The name of the directory comes from a string, but this string sometimes contains ", ' / etc characters, which prevents the directory-creation.
    So the question is simple, how could I remove these characters from myString variable?

    Thank you
    Last edited by HarryKlein; 01-13-2012 at 11:46 AM.

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: creation of directory fails due to invalid characters

    Use below function in your macro to remove /.Same you can repeat for all un wanted charecters.

    mystring = Replace(mystring , "/", "")

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    Re: creation of directory fails due to invalid characters

    Thanks, however what I want to avoid is the multiple use of replace, I was hoping, that there is a solution, when I can type all the unwanted character only once.

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: creation of directory fails due to invalid characters

    I have given for three charecters /, ? , |.You can extend further.

    mystring = Replace(Replace(Replace("mystring", "/", ""), "?", ""), "|", "")

  5. #5
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    Re: creation of directory fails due to invalid characters

    Thanks a lot.
    That helped a lot

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1