LoginSignup
1
0

More than 1 year has passed since last update.

Python プログラムを開く(ExcelやPowerPoint)

Posted at

Pythonで作ったExcelやPowerPonitファイルを最後開きたくなり、調べてやったことことです

使うのはsubprocess

import subprocess

fullpath_xlsx = r'C:\Users\XXX\Documents\aaa.xlsx'  
subprocess.Popen(['start', fullpath_xlsx], shell=True)

これでfullpath.xlsxファイルが開くはずです。
やってみたら、なぜか開かない。
'start'で登録されている実行ファイルはいいはずなんだけど。。。
ということで、Excelの実行ファイルを探し、そのpathを使い実行しました。

import subprocess

fullpath_xlsx = r'C:\Users\XXX\Documents\aaa.xlsx'
xlsx_act_path = r'C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE'
subprocess.Popen([xlsx_act_path , fullpath_xlsx], shell=True)

PowerPointの場合も同じ、ファイルのPathをPowerPointにすればよいだけです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0