>>> import subprocess >>> subprocess.Popen([r"C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" "\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb" /x WSorderMacro]) SyntaxError: invalid syntax >>>and also tried
>>> import subprocess >>> subprocess.Popen([r"C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" "\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb""WSorderMacro"]) Traceback (most recent call last): File "<pyshell#41>", line 1, in <module> subprocess.Popen([r"C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" "\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb""WSorderMacro"]) File "C:\Python26\ArcGIS10.0\lib\subprocess.py", line 633, in __init__ errread, errwrite) File "C:\Python26\ArcGIS10.0\lib\subprocess.py", line 842, in _execute_child startupinfo) WindowsError: [Error 3] The system cannot find the path specifiedand get errors. Thanks again for all your help so far it has been much aprreciated:)
subprocess.Popen([r"C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE", r"\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb", r"/x WSorderMacro"])
import subprocess subprocess.Popen(r'"C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" "\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb" /X WSorderMacro')
subprocess.Popen([r'C:\Program Files\Microsoft Office\OFFICE11\EXCEL.exe',r'C:\GIS Projects\TaxChange\Export\Change.xls'])
>>> import subprocess >>> subprocess.Popen([r'C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE',r'\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb'])I am having one small issue when I save the file as a .py file type and then double click on the file nothing happens. How do I make this script into a .py file and run the script off of that.
import subprocess def MacroAccess(when): if when == 'Nightly': #either Nightly or Weekly program = r'"C:\Program Files (x86)\Microsoft Office\OFFICE11\msaccess.exe" "c:\ftp\import2.mdb " /x NightlyBatch' elif when == 'Weekly': program = r'"C:\Program Files (x86)\Microsoft Office\OFFICE11\msaccess.exe" "c:\ftp\import2.mdb " /x WeeklyBatch' else: return 'no' print when + 'batch' subprocess.call(program) return when + 'Batch has run' print 'done' print MacroAccess('Nightly')
I know this is an old thread but this seems to work for me:
import os
filepath = r"C:\project_front.accdb"
os.system("start MSACCESS.EXE {}".format(filepath ))
Thanks Wes, I just updated.
Luke shouldn't line 4 be
os.system("start MSACCESS.EXE {}".format(filepath))