Hello I have a question regarding excel vba. If i want to call a python program using Excel VBA, but it has a whitespace I get a crash. For example:
Dim shell As Object
Dim exePath As String
Dim scriptPath As String
Set shell = VBA.CreateObject("Wscript.shell")
exePath = """C:\Users\****\Anaconda3\python.exe"""
scriptPath = "C:\Users\****\Desktop\Hello World\Hello_World.py"
shell.Run "cmd /k " & exePath & " " & scriptPath
when I try to run this code, the argument to the shell truncates at \Desktop\Hello, I have tried wrapping scriptPath with another set of quotes which creates a compile error, while wrapping it in chr(34) creates an error saying the filename, directory name, or volume label syntax is incorrect. I have also tried wrapping the entire shell.Run line with chr(34) which leads to Runtime Error Method Run of shell failed. Is there any way around this issue or is it just a VBA limitation? I should mention that running it directly in the command line is perfectly fine, it seems entirely an issue of running it in VBA