Open Application Argument with Spaces

Hello!

I’m trying to use the Open Application activity to open MS Access and give it a specified file name. I am able to get this to work if the path does not contain spaces. However, if the path does contain spaces, I am unable to get this to work. I have already searched the forum and found this topic, but it does not address the situation where the file name contains spaces.

For example, this works:

FileName: "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE"
Arguments: "MSACCESS.EXE C:\Users\Me\FolderWithoutSpaces\database.accdb"

But these do not work:

Arguments: "MSACCESS.EXE C:\Users\Me\Folder with Spaces\database.accdb"
Arguments: "MSACCESS.EXE 'C:\Users\Me\Folder with Spaces\database.accdb'"
Arguments: "C:\Users\Me\Folder with Spaces\database.accdb"

MS Access will start with the error message:

The command line you used to start Microsoft Access contains an option that Microsoft Access doesn't recognize

Is there any documentation of how the Arguments field works? Any help would be appreciated!

Thanks!

3 Likes

Try using this argument (3 quotation marks " in front and back of filepath):

“”“C:\Users\Me\Folder with Spaces\database.accdb”“”

7 Likes

@Dave, thank you! That works:

Arguments: "MSACCESS.EXE ""C:\Users\Me\Folder with Spaces\database.accdb"""

Any idea why this works? Thanks, again!

Just hunch based on the error message. It looks like it is using the command line (cmd.exe) to open the file based on the arguments you pass.

When using cmd, if the file has whitespace in the name, then you have to use double quotes (") around the file path. Otherwise it stops reading it as soon as the first space appears.

EDIT: I forgot to mention that you use the “program.exe ““C:\here is the path””” rather than “program.exe “C:\here is the path”” because if you only use a single " then UiPath thinks it is an end quote, notating the end of your string. Using the double “” escapes that and UiPath knows you are trying to pass a literal " in the string

2 Likes

Hi, I have the exact same problem but my Path comes in a variable. I tried the quotes and other variations but nothing worked. Any idea how it would work in my case?

If you use a variable for the file path, you have to use:

"MSACCESS.EXE " + """" + AccdbFilePath + """"

That’s four quotes.

6 Likes

Yes it works perfectly. That’s weird I thought I already tried 4 quotes. Anyway thanks a lot for your quick reply!

1 Like