After replies I tried the following.
strUrl = escape(strUrl) but this resulted the strUrl to be fully encoded even the / and \ slashes.
Then I started checking different Urls as suggested changing my / to \ slashes as well as encoding spaces. This was my result.
When I use the url withoud encodeing spaces like
"\\myserver\HelpDocumentation\Configuration - Company Configuration.pdf#Search=Register_"
in chrome it does not encode at all and at every space in the url it opens a new tab. – Not working.
When I use
in chrome it changes to :
Then not working because of double encoding. So it adds a “file:” and also encodes the url again, spaces and # is encoded.
When I use
in chrome it stays the same and in result it is working. So the “file:” appended at the start and encoding just the spaces in the url makes the difference.
I ended up with the following code. Note the strUrl is a input variable I just hardcoded for example. I also now check if its a pdf then add “file:” as the url can be a file or a report url. This code works.
Dim strChrome Dim WShellChrome Dim strUrl Set WShellChrome = CreateObject("WScript.Shell") strChrome = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe""" strUrl = "\\myserver\HelpDocumentation\Configuration - Company Configuration.pdf#Search=Register_" strUrl = Replace(strUrl, " ", "%20") if(InStr(strUrl,".pdf")) Then strUrl = "file:" + strUrl End If WShellChrome.Run strChrome & " " & ""+strUrl+"" , 1, false
CLICK HERE to find out more related problems solutions.