I would like to execute a shell script in Excel with VBA. However, I need to use quotes "
inside of my command. To figure out how I can escape quotes in the function MacScript
I simply try it with a simple command but I fail all the time.
So, here is a working example:
Function HTTPGet2() As String
HTTPGet2 = MacScript("do shell script ""echo 'hello' """)
End Function
Output: hello
But now I want to display he"llo"
. Both of the following examples I've tried already and both of them failed..
Try 1:
Function HTTPGet2() As String
HTTPGet2 = MacScript("do shell script ""echo 'he""llo""' """)
End Function
Try 2:
Function HTTPGet2() As String
HTTPGet2 = MacScript("do shell script ""echo 'he"& Chr(34) &"llo"& Chr(34) &"' """)
End Function
Can you guys please explain me why it doesn't work and how to make it work? I'm using Excel 2019 and MacOs on 10.14.4 (18E226)
At the end this is the command I want to execute:
xmllint --html -xpath 'string(//*[@id="AssetAllocationLongShortTable1"]/table/tbody/tr[1]/td[1])' http://tools.morningstar.de/de/xray/default.aspx\?LanguageId\=de-DE\&PortfolioType\=2\&SecurityTokenList\=F000000EM3\]2\]0\]ETEXG$XETR\|F00000J8T2\]2\]0\]FODEU$$ALL\&values\=50.00\|50.00\&CurrencyId\=EUR\&from\=editholding
But this isn't working as well..:
Function HTTPGet2() As String
HTTPGet2 = MacScript("do shell script "" xmllint --html -xpath 'string(//*[@id\""AssetAllocationLongShortTable1\""]/table/tbody/tr[1]/td[1])' http://tools.morningstar.de/de/xray/default.aspx\?LanguageId\=de-DE\&PortfolioType\=2\&SecurityTokenList\=F000000EM3\]2\]0\]ETEXG$XETR\|F00000J8T2\]2\]0\]FODEU$$ALL\&values\=50.00\|50.00\&CurrencyId\=EUR\&from\=editholding """)
End Function