TOP > AcroExch.PDDoc > Create [...]
説明
空のPDFドキュメント(AcroExch.PDDocインスタンス)を作成します。
形式
VARIANT_BOOL Create();
引数
- 無し。
戻り値
- -1:成功。作成出来た。
- 0:失敗。またはAcrobatアプリケーションがその機能をサポートしていない。
動作するバージョン
Version | Adobe Acrobat | 備考 |
---|---|---|
4 | - | Acrobat 4.0 ※Windows 98SE + Excel 2000 |
5 | - | Acrobat 5.0.5 |
6 | - | Acrobat 6.0.3 Pro |
7 | - | Acrobat 7.0.9 Pro Acrobat 7.1.4 Pro |
8 | OK | Acrobat 8.1.2 Pro |
9 | - | Acrobat 9.3.2 Extended |
10 | - | Acrobat X (10.1.8) Extended |
11 | - | Acrobat XI (11.0.04) Extended |
- OK = 動作する。
- NO = 動作しない。 戻り値が0を返す。
- - = 未確認。
サンプル:ExcelのVBA
説明:空のPDFファイルを作成し、それにTest01_1.pdfファイルの最初から裏表紙の前のページまでを挿入する。
そしてTest01_NEW.pdfファイルとして出力する。しおりも同時に入れる。
- F8キーでステップ実行しながら動作確認する。
- 事前に参照設定を事前にする。
001 Sub AcroExch_PDDoc_Create()
002
003 Dim AcroPDDocNew As New Acrobat.AcroPDDoc
004 Dim AcroPDDocAdd As New Acrobat.AcroPDDoc
005 Dim lRet As Long
006 Dim lGetNumPages As Long
007
008 '空のPDFファイルを作成する
009 lRet = AcroPDDocNew.Create()
010
011 '空のPDFファイルに追加する
012 lRet = AcroPDDocAdd.Open("E:\Test01_1.pdf")
013 lGetNumPages = AcroPDDocAdd.GetNumPages()
014 '1ページ目から裏表紙の前のページまでを最初のページの前に挿入。
015 lRet = AcroPDDocNew.InsertPages(-1, _
016 AcroPDDocAdd, 0, lGetNumPages - 1, True)
017 Debug.Print "AcroPDDocNew.GetNumPages=" & _
018 AcroPDDocNew.GetNumPages
019 lRet = AcroPDDocAdd.Close()
020
021 '新しいPDFファイルを別名で保存する
022 lRet = AcroPDDocNew.Save(1, "E:\Test01_NEW.pdf")
023 lRet = AcroPDDocNew.Close()
024
025 'オブジェクトを強制開放する
026 Set AcroPDDocAdd = Nothing
027 Set AcroPDDocNew = Nothing
028
029 End Sub
Highlight:プログラミング言語のソースコードを構文で色分け (GUI編)
補足
- 上記サンプルはサイレント(Acrobat本体が画面に表示されない)で実行されます。
- Create メソッドの後に、Saveメソッド、そしてCloseメソッドを実行すれば0ページのPDFドキュメントが作成されます。
例)001 Sub AcroExch_PDDoc_Create2() 002 Dim AcroPDDocNew As New Acrobat.AcroPDDoc 003 Dim AcroPDDocAdd As New Acrobat.AcroPDDoc 004 Dim lRet As Long 005 Dim lGetNumPages As Long 006 007 '空のPDFファイルを作成する 008 lRet = AcroPDDocNew.Create() 009 '空のPDFファイルを保存する 010 lRet = AcroPDDocNew.Save(1, "E:¥Test01_NEW.pdf") 011 lRet = AcroPDDocNew.Close() 012 013 'オブジェクトを強制開放する 014 Set AcroPDDocAdd = Nothing 015 Set AcroPDDocNew = Nothing 016 End Sub
動作確認環境
- WindowsXP Pro(+ SP3) +
Acrobat 8.1.2 Pro + Office 2003 + フルMicrosoftUpdate
< 戻る >