関数:PDFファイルを完全にチェックする

TOP > サンプル/関数 > 関数:PDFファイルを完全にチェックする      [...]


機能

PDFファイルに対して以下の3点をチェックする

  1. ファイルの存在チエック
  2. 拡張子 PDFのチェック
  3. ファイルにPDFバージョン情報が存在するかのチェック

形式

001 [boolean] = Check_PDF_W_nnn2( 002 string strFilePath , 003 string strMessage )

引数

  1. 第一引数 ( string strFilePath ) :
    PDF ファイルのフルパス
  2. 第二引数 ( string strMessage ) : 
    エラー時のメッセージ 
    ””の場合はエラー無し、そして正常なPDFを意味する

戻り値

  1. True : 正常なPDFファイル
  2. False : PDFファイルで無い。
    又は処理途中で実子エラー発生。

動作するバージョン

Microsoft
Excel
結果
備考
2000
NO
※OS : Windows 98SE
XP
-
※Office XP [=2002]
2003
-
Windows XP Pro (SP3)
2007
OK
Windows 7 64bit Home (SP1)
2010
-
 
  • OK : 正常処理する。
  • NO : 正常に処理できない。 
  • - : 未確認。 

VBAサンプル

Downloadsample-CheckPDF.xls

001 Option Explicit 002 003 Sub Check_PDF_W_nnn2_TEST() 004 005 Const CON_FILE = "I:¥Adobe PDF¥pdf_ref.pdf" 006 Dim strMsg As String 007 Dim bRet As Boolean 008 009 bRet = Check_PDF_W_nnn2(CON_FILE, strMsg) 010 011 Debug.Print "bRet = " & bRet 012 End Sub 013 014 '************************************************** 015 ' 016 ' PDFを完全にチェックする 017 ' Check exactly the PDF 018 ' 019 ' 1. PDFファイルの存在チエック 020 ' 2. 拡張子がPDF 021 ' 3. PDFバージョンを持ったファイル 022 ' 023 ' Create : 2013/10/07 024 ' Update : 025 ' Vertion : 1.0.0 026 ' 027 ' 引数1 : sFilePath As String (IN) 028 ' PDFファイルのフルパス 029 ' 引数2 : strMessage As String (OUT) 030 ' エラーメッセージ 031 ' ""はエラー無し 032 ' 033 ' 戻り値 : True 正常処理 034 ' False 実行エラー又はPDFで無い 035 ' 036 ' 備考 : PDFファイルに対して3つのチェックを行う 037 ' URL : http://pdf-file.nnn2.com/?p=766 038 ' その他 : 著作権等は主張しません。 039 ' 上記URLにコメントを頂けると嬉しいです。 040 ' 041 '************************************************** 042 043 Public Function Check_PDF_W_nnn2( _ 044 ByVal strFilePath As String, _ 045 ByRef strMessage As String) As Boolean 046 On Error GoTo Err_Check_PDF_W_nnn2: 047 048 Dim strPDFVersion As String 049 Dim lAcrbatV As Long 050 051 strFilePath = Trim$(strFilePath) 052 053 'PDFファイルの存在チエック 054 If Dir$(strFilePath) = "" Then 055 strMessage = "1. Not found file (" & strFilePath & ")" 056 Check_PDF_W_nnn2 = False 057 Exit Function 058 End If 059 060 '拡張子がPDF 061 If LCase$(Right$(strFilePath, 4)) <> ".pdf" Then 062 strMessage = "2. Not extension pdf (" & strFilePath & ")" 063 Check_PDF_W_nnn2 = False 064 Exit Function 065 End If 066 067 'PDFバージョンを持ったファイル 068 If Not Get_PDF_Version_nnn2( _ 069 strFilePath, strPDFVersion, lAcrbatV) Then 070 'PDFファイルでは無い 071 strMessage = "3. Not pdf file (" & strFilePath & ")" 072 Check_PDF_W_nnn2 = False 073 Exit Function 074 End If 075 076 '正常なPDFファイル 077 Check_PDF_W_nnn2 = True 078 strMessage = "" 079 080 Exit Function 081 082 Err_Check_PDF_W_nnn2: 083 '実行エラー発生 084 strMessage = "Run time error " & Err.Number & " " & Err.Description 085 Check_PDF_W_nnn2 = False 086 End Function


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

備考

  1. 内部で使ってる Get_PDF_Version_nnn2 関数は
    PDFのバージョンを取得する」を使う。

動作確認環境

  • Windows 98SE (WindowsUpdate) + Excel 2000 (SP3)
  • Windows XP Pro (SP3 + WindowsUpdate) + Excel XP (SP3)
  • Windows XP Pro (SP3 + WindowsUpdate) + Excel 2003 (SP3)
  • Windows 7 64bit Home  (SP1 + MicrosoftUpdate) + Excel 2007 (SP3)

サンプル一覧

コメントを残す

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

CAPTCHA


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


SAMURAI Plugin

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

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



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

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