AnonymousX Posted February 7, 2017 Share Posted February 7, 2017 (edited) Hi, I'm trying to create a program where the user can input a material number into a GUI and the script will search out and find the respected material folder. I've been able to piece together the file mapping part so that the correct folder is stored within a variable. However I can not seem to get the Run function to work as the directory contains commas. Could I please get assistance with this? Here is some test code I've experimented with $filepath = "C:\Users\annoymousx\Documents\" ; Variable Works ;$filepath = "C:\Users\annoymousx\Documents\Test with Spaces\"; Works with folder spacing $filepath = $filepath & "Test with Spaces\"; Works with using a prior directory history $filepath = $filepath & "Folder with ()"; Works if brackets are used ;$filepath = $filepath & "\Folder with ," ;Does not Work if comma is used in file directory $filepath = $filepath & "\Folder with " & ""","""; Works if triple brackets are used Run("explorer.exe " & $filepath) So I've learnt if you put triple quotations around a comma it will work correctly. The challenge is, in the actual script i'm not manually entering in text. Example: $filepath = $filepath & $Materialclass[$classnum] & "\" Which is put into a loop, then at the end of the script I have the correct file path saved to the variable but it may contain many commas. How would I take this variable with the correct file path and open windows explore to it? Say if the variable contained the value: C:\Users\anonymousx\Documents\This folder has a ,\comma, (comma, comma,)\And more , here Thanks for any suggestions, Edited February 7, 2017 by AnonymousX Link to comment Share on other sites More sharing options...
Subz Posted February 7, 2017 Share Posted February 7, 2017 Just use single/double quotes for example: Run('Explorer.exe "' & $hFileName & '"') AnonymousX 1 Link to comment Share on other sites More sharing options...
AnonymousX Posted February 7, 2017 Author Share Posted February 7, 2017 13 hours ago, Subz said: Just use single/double quotes for example: Run('Explorer.exe "' & $hFileName & '"') Worked like a charm! Thanks that was an easy fix for what I thought was going to be a big headache Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now