Groups
Sign in
Groups
excella
Conversations
About
Send feedback
Help
Excel2010を利用したPDF化
984 views
Skip to first unread message
iti
unread,
Jan 24, 2011, 8:54:34 PM
1/24/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to excella
いつもお世話になっております。
Excel2010ではPDF出力が標準でサポートされているので試してみました。
「Excelアドインを利用したPDF化」を参考にしてExcel2010で実行したところ、
問題なくPDF出力できました。
ご参考までにご報告します。
また、PDF出力のマクロを各テンプレートに組み込むのが嫌だったので、
マクロ部分を外だしにしてみました。
1.closePdf関数をテキストファイルに保存
例)closePdf.vbs
2.外部マクロをincludeさせた上でpdf出力するマクロ作成
(book全体をPDF出力しかしていませんが)
Dim app
'On Error Resume Next
'Err.Clear
Set app = CreateObject("Excel.Application")
' Excelは非表示にする
app.Visible = False
' ダイアログを非表示にする
app.DisplayAlerts = False
' 引数のチェック、ファイルを開く
Set args = WScript.Arguments.Named
If args.Exists("file") Then
' ファイルを開く
Set workbook = app.Workbooks
workbook.Open args("file")
Set book = app.ActiveWorkbook
'PDF出力用マクロをinclude
book.VBProject.VBComponents.Import args("outvbs")
'PDF出力実行
app.Run "closePdf" , args("outfname")
' アプリケーション終了
app.Quit
Set book = Nothing
Set workbook = Nothing
End If
app.DisplayAlerts = True
Set app = Nothing
3.このファイルをpdfExport.vbsとすると、こんな感じで呼び出します。
pdfExport /file:変換元Excelのフルパス /outfname:出力するPDFのフルパス /outvbs:closePdf関数
を記述したVBSファイルへのフルパス
4.但し、外部からVBAマクロをExcelにねじ込んでいるのでExcelのセキュリティ設定を行う必要があります。
Excelでファイル→オプション→セキュリティセンター→セキュリティセンターの設定→マクロの設定→
VBAプロジェクトオブジェクトモデルへのアクセスを信頼するにチェック
以上、ご参考になれば幸いです。
横井@bbreak
unread,
Jan 25, 2011, 8:09:19 PM
1/25/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to excella
横井です。
情報共有ありがとうございます。
こういう情報を頂けると非常にありがたいです。
今後ともよろしくお願いします。
Reply all
Reply to author
Forward
0 new messages