Luke shouldn't line 4 be
os.system("start MSACCESS.EXE {}".format(filepath))
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.
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')
>>> import subprocess >>> subprocess.Popen([r'C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE',r'\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb'])
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" "\\vopcc\gis\GISOPS\StreetNetwork\Routing.mdb" /X WSorderMacro')
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]) SyntaxError: invalid syntax >>>
>>> 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 specified
>>> import subprocess ... subprocess.Popen([r"c:\programs files\Microsoft office\office12\msaccess.exe"]) ... Runtime error <type 'exceptions.WindowsError'>: [Error 3] The system cannot find the path specified
import subprocess subprocess.Popen([r"c:\programs files\Microsoft office\office12\msaccess.exe"])
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.