Hi,
This seems to be a solution specific to the built-in interpreter in Origin:
import os
import sys
os.add_dll_directory('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\pywin32_system32')
sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32')
sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32\\lib')
from win32com.client import Dispatch
Edit:
An explanation...
The pywin32 package has a "post installation" script that must be run as an administrator because it copies two DLLs to the `C:\WINDOWS\system32` folder. As well, it modifies your `Path` environmental variable. It would be difficult to run that post install script as admin because not everyone has admin access on their PC. It would be a hassle.
So, this line in the code above prevents the need to copy the DLLs by pointing the interpreter to look at the original source of the DLLs:
os.add_dll_directory('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\pywin32_system32')
Now, if you modified your actual Path environmental variable for an Origin-embedded specific package, it may cause problems with an external Python installation. So, instead of worrying about modifying your actual Path variable, we use these two lines that temporary modify it for the embedded instance of Python only:
sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32')
sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32\\lib')
Finally, what is this path: C:\ProgramData\OriginLab\PyPackage\Py38\64bit ??? That is where Origin install packages when you install them from within the product.
Thanks,
Chris Drozdowski
Originlab Technical Support