AFormAut : Field.TextFont プロパティ

TOP > AFormAut > AFormAut : Field.TextFont プロパティ


説明

テキストフィールド、コンボボックス、リストボックス、またはボタンに配置するテキストのフォントを示します。

形式

[ 取得 / 設定 ] String

設定又は戻り値

設定、又は取得可能なフォント

  1. HeiseiMin-W3-UniJIS-UCS2-H (平成明朝)
  2. HeiseiKakuGo-W5-UniJIS-UCS2-H (平成角ゴシック)
  3. Courier
  4. Courier-Bold
  5. Courier-Oblique
  6. Courier-BoldOblique
  7. Helvetica
  8. Helvetica-Bold
  9. Helvetica-Oblique
  10. Helvetica-BoldOblique
  11. Symbol
  12. Times-Roman
  13. Times-Bold
  14. Times-Italic
  15. Times-BoldItalic
  16. ZapfDingbats

フォーム機能で使用可能な日本語フォントは、平成明朝、平成角ゴシック のみです。

"平成明朝" では無く "HeiseiMin-W3-UniJIS-UCS2-H" と指定します。

動作するバージョン

Adobe
Acrobat
  結果備考
4Acrobat 4.0 ※Windows 98SE + Excel 2000 *1
5Acrobat 5.0.5 + Excel 2003 *1
6Acrobat 6.0.6 Pro + Excel 2003 *1
7OKAcrobat 7.1.4 Pro + Excel 2003 *2
8NOAcrobat 8.3.1 Pro + Excel 2003
※当Acrobatバージョンでは全面的に不可
9NOAcrobat 9.5.2 Extended + Excel 2003
※当Acrobatバージョンでは全面的に不可
10OKAcrobat X (10.1.4) Extended + Excel 2003
11OKAcrobat XI (10.0) Extended + Excel 2003
  • OK : 正常処理する。
  • NO : 動作しない。 又は実行時にエラーになる。
  • *1 : 「PDF のバージョン」によっては正常処理出来ない場合がある。
    詳細は下の 注意 を参照ください。
  • *2 : 処理前のレジストリに以下を追加する必要があります。
    [HKEY_CURRENT_USER¥Software¥Adobe¥Adobe Acrobat¥7.0¥AVAlert]
    [HKEY_CURRENT_USER¥Software¥Adobe¥Adobe Acrobat¥7.0¥AVAlert¥cCheckbox]
    "idocNewerVersionWarning"=dword:00000001

サンプル:ExcelのVBA

  1. 説明:PDFファイルの各ページにヘッダーを追加する。
  2. F8キーでステップ実行しながら動作確認します。
  3. 事前に 参照設定(AFormAutの追加版) が必要です。

変数の宣言 Integer は Long でご使用ください。

001 Option Explicit 002 003 Sub AFormAut_Field_TextFont() 004 On Error GoTo Err_AFormAut_Field_TextFont: 005 006 Dim i As Integer 007 Dim iPageNum As Integer 008 Dim bRet As Boolean 009 Dim bEnd As Boolean 010 Dim sFilePath_new As String 011 Dim objAFormApp As AFORMAUTLib.AFormApp 012 Dim objAFormFields As AFORMAUTLib.Fields 013 Dim objAFormField As AFORMAUTLib.Field 014 015 '初期値 016 Const CON_FILEPATH = "c:¥work¥sample.pdf" 017 bEnd = True 018 019 'Acrobatオブジェクトの定義&作成 020 021 'Acrobat 4,5,6 の時 022 ' Dim objAcroApp As Acrobat.CAcroApp 023 ' Dim objAcroAVDoc As Acrobat.CAcroAVDoc 024 ' Dim objAcroPDDoc As Acrobat.CAcroPDDoc 025 ' Dim objAcroPDPage As Acrobat.CAcroPDPage 026 ' Dim objAcroPoint As Acrobat.CAcroPoint 027 ' Set objAcroApp = CreateObject("AcroExch.App") 028 ' Set objAcroAVDoc = CreateObject("AcroExch.AVDoc") 029 ' Set objAcroPDDoc = CreateObject("AcroExch.PDDoc") 030 031 'Acrobat 7,8,9,10,11 の時 032 Dim objAcroApp As New Acrobat.AcroApp 033 Dim objAcroAVDoc As New Acrobat.AcroAVDoc 034 Dim objAcroPDDoc As New Acrobat.AcroPDDoc 035 Dim objAcroPDPage As Acrobat.AcroPDPage 036 Dim objAcroPoint As Acrobat.AcroPoint 037 038 '※CreateObject("AFormAut.App")のエラー 039 '※[429 ActiveXコンポーネントはオブジェクトを作成できません。] 040 '※回避用 / メモリにAcrobatを強制ロードさせる 041 objAcroApp.CloseAllDocs 042 043 '処理対象のPDFファイルを開く 044 bRet = objAcroAVDoc.Open(CON_FILEPATH, "") 045 046 If bRet = False Then 047 MsgBox "AVDocオブジェクトはOpen出来ません", _ 048 vbOKOnly + vbCritical, "処理エラー" 049 bEnd = False 050 GoTo Skip_AFormAut_Field_TextFont: 051 End If 052 053 Set objAcroPDDoc = objAcroAVDoc.GetPDDoc 054 iPageNum = objAcroPDDoc.GetNumPages 055 Set objAFormApp = CreateObject("AFormAut.App") 056 Set objAFormFields = objAFormApp.Fields 057 058 For i = 0 To iPageNum ― 1 059 060 'PDFページサイズを取得 061 Set objAcroPDPage = objAcroPDDoc.AcquirePage(i) 062 Set objAcroPoint = objAcroPDPage.GetSize 063 064 '指定ページにヘッダー用のテキストフィールドを追加 065 Set objAFormField = _ 066 objAFormFields.Add("Header" & (i + 1), "text", _ 067 i, (objAcroPoint.x / 2100), _ 068 (objAcroPoint.y15), _ 069 (objAcroPoint.x / 2 + 100), _ 070 (objAcroPoint.y35)) 071 072 'テキストフィールドの各種設定 073 With objAFormField 074 .SetBackgroundColor "RGB", 1, 1, 1, 0 075 .Alignment = "center" 076 .TextFont = "HeiseiMin-W3-UniJIS-UCS2-H" 077 .Value = "Header " & Now() '表示する文字 078 .IsReadOnly = True '読み込み専用 079 .IsHidden = False '表示 080 End With 081 082 '設定後に開放 083 Set objAFormField = Nothing 084 085 Next 086 087 'PDFファイルを別名で保存 088 sFilePath_new = Replace(CON_FILEPATH, ".pdf", "_new.pdf") 089 bRet = objAcroPDDoc.Save(1, sFilePath_new) 090 If bRet = False Then 091 MsgBox "PDFファイルへ保存出来ませんでした", _ 092 vbOKOnly + vbCritical, "エラー" 093 bEnd = False 094 End If 095 096 'PDFファイルを閉じる 097 bRet = objAcroAVDoc.Close(False) 098 If bRet = False Then 099 MsgBox "AVDocオブジェクトはClose出来ませんでした", _ 100 vbOKOnly + vbCritical, "処理エラー" 101 bEnd = False 102 End If 103 104 Skip_AFormAut_Field_TextFont: 105 On Error Resume Next 106 '変更しないで閉じます。 107 bRet = objAcroAVDoc.Close(False) 108 109 'Acrobatアプリケーションの終了 110 objAcroApp.Hide 111 objAcroApp.Exit 112 113 'オブジェクトの開放 114 Set objAFormFields = Nothing 115 Set objAFormApp = Nothing 116 Set objAcroPDPage = Nothing 117 Set objAcroPoint = Nothing 118 Set objAcroPDDoc = Nothing 119 Set objAcroAVDoc = Nothing 120 Set objAcroApp = Nothing 121 122 If bEnd = True Then 123 MsgBox "処理は正常に終了しました。", _ 124 vbOKOnly + vbInformation, "正常終了" 125 End If 126 127 Exit Sub 128 129 '実行エラー(Runtime Error) 130 Err_AFormAut_Field_TextFont: 131 MsgBox Err.Number & vbCrLf & Err.Description, _ 132 vbOKOnly + vbCritical, "実行時のエラー" 133 bEnd = False 134 GoTo Skip_AFormAut_Field_TextFont: 135 End Sub


 Highlight:プログラミング言語のソースコードを構文で色分け (GUI編)
 


実行結果

Acrobat 7.1.4 実行時の結果

AFormAut : Field.TextFont プロパティ(実行結果)

備考

  1. 特に無し。

注意

  1. 他の日本語フォントが既に PDFファイル に組み込まれていても使用は出来ません。
    MS-Gothic : MS ゴシック
    MS-Mincho : MS 明朝
    MS-PGothic : MS Pゴシック
    MS-PMincho : MS P明朝
    AFormAut : Field.TextFont プロパティ(フォント)
     
  2. Field.Textfont = "MS-Mincho"
    を事項すると 実行エラー(Runtime Error) となる。
    -2147467259 オートメーション エラーです。エラーと特定できません
    AFormAut : Field.TextFont プロパティ(実行エラー)
  3. 更にこの後で強制的に AVDoc.close メソッドを実行すると、
    以下が限りなく表示され、VBAが終了しなくなる。
    別のプログラムでOLEの操作が完了するまで待機を続けます。
    AFormAut : Field.TextFont プロパティ(実行エラー)
  4. 全OLEを実行する前に
    objAcroApp.CloseAllDocs
    で強制的にAcrobat アプリケーションをメモリ上にロードしないと
    Set objAFormApp = CreateObject("AFormAut.App")
    で実行エラー(ランタイムエラー)が発生する場合があります。
    429 ActiveXコンポーネントはオブジェクトを作成できません。
    429 ActiveXコンポーネントはオブジェクトを作成できません。

動作確認の環境

  • Acrobat 4.0 + Office 2000
    +  Windows98SE( + WindowsUpdate)
  • Acrobat 5.0.5 + Office 2003( + SP3)
    +  WindowsXP Pro( + SP3 + WindowsUpdate)
  • Acrobat 6.0.6 Pro + Office 2003( + SP3)
    +  WindowsXP Pro( + SP3 + WindowsUpdate)
  • Acrobat 7.1.4 Pro + Office 2003( + SP3)
    +  WindowsXP Pro( + SP2 + WindowsUpdate)
  • Acrobat 8.3.1 Pro + Office 2003( + SP3)
    +  WindowsXP Pro( + SP3 + WindowsUpdate)
  • Acrobat 9.5.2 Extended + Office 2003( + SP3)
    +  WindowsXP Pro( + SP3 + WindowsUpdate)
  • Acrobat X (10.1.4) Extended + Office 2003( + SP3) 
    + WindowsXP Pro( + SP3 + WindowsUpdate)
  • Acrobat XI (11.0) Extended + Office 2003( + SP3)
    + WindowsXP Pro( + SP3 + WindowsUpdate)

Adobe Web 解説 URL(英語)

v10.0

http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/IAC_API_FormsIntro.107.37.html

戻る

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


★ 文章での質問は難しいですよネ。でも、早く解決して、家に帰りたい。


SAMURAI Plugin

コメントをする時は出来れば以下もお願いします。

  • OS名 バージョン
  • Acrobat バージョン
  • ツール(Excel等) バージョン
コメントにサンプルコードを入れる時はコードを全て全角文字列にしてください。コチラで半角に戻します。それでもエラーが回避できない時はコメント下さい。個別に対処します。



お仕事で当サイトを見ている方へ
考え込んだら、ご質問下さい。
一緒に解決策を考えましょう。

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください