I want to open files from a networklocation from VBA, only normal users don't have access to that location (and should preferably not get it).
I instead of using shell("explorer.exe filepath") to open files using windows standard app for the file, which needs userpermissions to the path the file is located, for the currently logged in user.
I'm trying to use CPAU in combination with Shell, because using CPAU you can pass a user/password that has permission to open a process
The only problem is that the filepaths have spaces in them and that is Always a bit of a tricky thing to tackle.
So, for example, this works:
But I cannot get it to work with a file that is on a path with a space in it (or with a space in the name), like
I'm trying all kinds of thinks:
- adding chr(34) at certain places
- using """
- the above in different versions
But to this point without result.
Trying to figure out the plain cmdline:
Works:
Doesnt work:
(difference in filename with a space in it)
The last command start explorer, but doesn't open the file (just as the first line I posted, it opens Explorer, but not the file. Must be something with the way I pass the filename?)
Also works in commandline
I instead of using shell("explorer.exe filepath") to open files using windows standard app for the file, which needs userpermissions to the path the file is located, for the currently logged in user.
I'm trying to use CPAU in combination with Shell, because using CPAU you can pass a user/password that has permission to open a process
The only problem is that the filepaths have spaces in them and that is Always a bit of a tricky thing to tackle.
So, for example, this works:
Code:
shell("N:\Guideline\Ontw\CPAU -u Domain\User -p password -LWOP -ex " & Chr(34) & "C:\windows\Explorer.exe c:\temp\test.pdf")
Code:
N:\Engineering\JB-MAT\BB\BB-004_Panel Pin\BB-004_Panel Pin.pdf
- adding chr(34) at certain places
- using """
- the above in different versions
But to this point without result.
Trying to figure out the plain cmdline:
Works:
Code:
N:\Guideline\Ontw\10_Ontw\cpau -u Domain/User -p Password -ex "c:\windows\Explorer.exe "c:\temp\test.pdf""
Code:
N:\Guideline\Ontw\10_Ontw\cpau -u Domain/User -p Password -ex "c:\windows\Explorer.exe "c:\temp\test 1.pdf""
The last command start explorer, but doesn't open the file (just as the first line I posted, it opens Explorer, but not the file. Must be something with the way I pass the filename?)
Code:
explorer.exe "C:\temp\test 1.pdf"
Last edited: