1
3

More than 1 year has passed since last update.

【Python】数行のコードで、複数Wordファイルを一括でPDFファイルに変換

Last updated at Posted at 2023-09-07

できること

  • フォルダ内のすべてのWordファイルを、一括でPDFファイルに変換する
    • 同じフォルダ内に、同じファイル名で保存されます。

実装

PDF化したいファイルたち

image.png

コード

- wd = win32com.client.Dispatch('Word.Application')がないと僕のPCではうまく動かなかったです[1]。Macなどの方は、ここを変更する必要があるかもしれません! (2023/9/7訂正)

from docx2pdf import convert

# 変換したいWordファイルがあるフォルダのパスを指定
folder_path = 'ここにパスを指定'

# フォルダ内のすべてのWordファイルをPDFに変換
convert(folder_path)

結果

  • 無事作成されてます!

image.png

参考記事

  1. 初心者がWordファイルを一括でPDFに変換してみる
1
3
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
3