関数:Acrobat , Adobe Reader のインストールパスとバージョンを取得

TOP > サンプル/関数 > 関数:Acrobat,Adobe Reader のインストールパスとバージョンを取得      [...]


機能

Acrobat , Adobe Reader のインストールパスとバージョンを取得する。

  1. Acrobat , Adobe Reader を指定可能
  2. Windows へのインストールパスはレジストリから取得
  3. インストールパスからアプリケーションのバージョン番号( '4'~'11' , '15' , '17')を取得
    • '4':Acrobat 4
    • '5':Acrobat 5
    • '6':Acrobat 6
    • '7':Acrobat 7
    • '8':Acrobat 8
    • '9':Acrobat 9
    • '10':Acrobat X
    • '11':Acrobat XI
    • '15':
      Acrobat.exe のインストールフォルダが
      • Acrobat DC ならば :Acrobat DC
      • Acrobat 2015 ならば:Acrobat DC(2015)
    • '17':Acrobat 2017

形式

001 [boolean] = Get_Adobe_App_Info_nnn2( 002 string strApp , 003 string strPath , 004 string strVersion , 005 string strMsg )

引数

  1. 第1引数 ( string sstrApp ) : 
    'Acrobat'  Acrobatの処理
    'Reader' Adobe Readerの処理
  2. 第2引数 ( string strPath ) :
    Acrobat , Adobe Reader へのフルパス
  3. 第3引数 ( string strVersion ) : 
    アプリケーションのバージョン番号  '4'~'11' , '15' , '17'
  4. 第4引数 ( string strMsg ) : 
    エラー時のメッセージ 
    ””の場合はエラー無し

戻り値

  1. True : 正常な処理
  2. False : 実行エラー等

動作するバージョン

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

VBAサンプル

Downloadsample-GetAdobeAppInfo.xls

001 Option Explicit 002 003 'Win32 APIを使用するための宣言 004 005 'Public Const HKEY_CLASSES_ROOT = &H80000000 006 'Public Const HKEY_CURRENT_USER = &H80000001 007 'Public Const HKEY_CURRENT_CONFIG = &H80000005 008 'Public Const HKEY_DYN_DATA = &H80000006 009 Public Const HKEY_LOCAL_MACHINE = &H80000002 010 'Public Const HKEY_USERS = &H80000003 011 'Public Const ERROR_SUCCESS = 0& 012 013 Type VS_FIXEDFILEINFO 014 dwSignature As Long 015 dwStrucVersion As Long 016 dwFileVersionMS As Long 017 dwFileVersionLS As Long 018 dwProductVersionMS As Long 019 dwProductVersionLS As Long 020 dwFileFlagsMask As Long 021 dwFileFlags As Long 022 dwFileOS As Long 023 dwFileType As Long 024 dwFileSubtype As Long 025 dwFileDateMS As Long 026 dwFileDateLS As Long 027 End Type 028 029 'レジストリのハンドルを解放する 030 Public Declare Function RegCloseKey Lib "ADVAPI32" _ 031 (ByVal hKey&) As Long 032 033 'レジストリのキーを開ける(ハンドルの確保) 034 Public Declare Function RegOpenKeyEx Lib "ADVAPI32" _ 035 Alias "RegOpenKeyExA" (ByVal hKey&, ByVal lpSubKey$, _ 036 ByVal ulOptions&, ByVal samDesired&, phkResult&) As Long 037 038 'レジストリの値を取得する 039 Public Declare Function RegQueryValueExstr Lib "ADVAPI32" _ 040 Alias "RegQueryValueExA" (ByVal hKey&, _ 041 ByVal lpValueName$, ByVal lpReserved&, ByVal lpType&, _ 042 ByVal lpdata$, lpcbData&) As Long 043 044 'ファイルのバージョン情報のサイズを取得する 045 Public Declare Function GetFileVersionInfoSize Lib _ 046 "Version.dll" Alias "GetFileVersionInfoSizeA" _ 047 (ByVal lptstrFilename As String, lpdwHandle As Long) _ 048 As Long 049 050 'ファイルのバージョン情報を取得する 051 Public Declare Function GetFileVersionInfo Lib "Version.dll" _ 052 Alias "GetFileVersionInfoA" _ 053 (ByVal lptstrFilename As String, ByVal dwHandle As Long, _ 054 ByVal dwLen As Long, lpdata As Any) As Long 055 056 Public Declare Function VerQueryValue Lib "Version.dll" _ 057 Alias "VerQueryValueA" (pBlock As Any, _ 058 ByVal lpSubBlock As String, lplpBuffer As Any, _ 059 puLen As Long) As Long 060 061 Public Declare Sub MoveMemory Lib "kernel32.dll" _ 062 Alias "RtlMoveMemory" (Destination As Any, _ 063 Source As Any, ByVal Length As Long) 064 065 '時間指定してCPUをシステムに戻す 066 Public Declare Sub Sleep Lib "kernel32.dll" _ 067 (ByVal dwMilliseconds As Long) 068 069 '******************************************************** 070 ' Windowsのレジストリから、アプリのインストールパスを取得 071 '******************************************************** 072 073 Private Sub Get_Adobe_App_Info_nnn2_Test() 074 075 Const CON_APP = "Acrobat" 'Acrobat 076 'Const CON_APP = "Reader" 'Adobe Reader 077 Dim strAcrobatPath As String 078 Dim strVersion As String 079 Dim strMsg As String 080 081 'Acrobat バージョンの取得 082 Call Get_Adobe_App_Info_nnn2(CON_APP, _ 083 strAcrobatPath, strVersion, strMsg) 084 085 Debug.Print "AcrobatPath ='" & strAcrobatPath & "'" & vbCrLf & _ 086 "Acrobat Version='" & strVersion & "'" & vbCrLf & _ 087 "Message ='" & strMsg & "'" 088 089 090 End Sub 091 092 '************************************************** 093 ' 094 ' Acrobat , Adobe Reader アプリのインストールパスと 095 ' アプリケーションのバージョンを取得する 096 ' 097 ' Get the version and application path 098 ' for acrobat and adobe reader. 099 ' 100 ' Create : 2013/10/08 101 ' Update : 102 ' Vertion : 1.0.0 103 ' 104 ' 引数1 : strApp As String (IN) 105 ' 'Acrobat' Acrobatの処理 106 ' 'Reader' Adobe Readerの処理 107 ' 引数2 : strPath As String (OUT) 108 ' Adobe アプリケーションパス 109 ' 引数3 : strVersion As String (OUT) 110 ' アプリケーションのバージョン番号 4~11 111 ' 引数4 : strMsg As String (OUT) 112 ' エラーメッセージ 113 ' ""はエラー無し 114 ' 115 ' 戻り値 : True 正常処理 116 ' False 実行エラー等 117 ' 118 ' 備考 : 119 ' 1. 以下のサイトの情報を元に作成しました 120 ' http://helpx.adobe.com/jp/acrobat/kb/511265.html 121 ' URL : http://pdf-file.nnn2.com/?p=767 122 ' その他 : 著作権等は主張しません。 123 ' 上記URLにコメントを頂けると嬉しいです。 124 ' 125 '************************************************** 126 127 Public Function Get_Adobe_App_Info_nnn2( _ 128 ByVal strApp As String, _ 129 ByRef strPath As String, _ 130 ByRef strVersion As String, _ 131 ByRef strMsg As String) As Boolean 132 133 On Error GoTo Err_Get_Adobe_App_Info_nnn2: 134 135 Dim strFileVersion As String 136 Dim strProductVersion As String 137 Dim strSubKey As String 138 Dim strRootKey As String 139 Dim InstallPathReg As Long 140 Dim lLength As Long 141 Dim lRet As Long 142 Dim strName As String 143 144 strMsg = "" 145 strRootKey = HKEY_LOCAL_MACHINE 146 If strApp = "Acrobat" Then 147 'Acrobat Reg 148 strSubKey = "SOFTWARE¥Microsoft¥Windows¥" & _ 149 "CurrentVersion¥App Paths¥Acrobat.exe" 150 Else 151 'Adobe Reader Reg 152 strSubKey = "SOFTWARE¥Microsoft¥Windows¥" & _ 153 "CurrentVersion¥App Paths¥AcroRd32.exe" 154 End If 155 156 'キーをオープンしてハンドルを得る 157 lRet = RegOpenKeyEx(strRootKey, strSubKey, 0, 1, _ 158 InstallPathReg) 159 160 'バッファを確保する 161 strPath = String(250, Chr(0)) 162 lLength = Len(strPath) '長さ 163 164 '"*.exe"エントリから既定のレジストリを得る 165 strName = "" 166 lRet = RegQueryValueExstr(InstallPathReg, strName, _ 167 0, 0, strPath, lLength) 168 169 'レジストリ値の存在チェック 170 strPath = Trim$(Replace(strPath, Chr(0), " ")) 171 If strPath = "" Then 172 'エラー:アプリケーションは未インストール 173 strMsg = "Not Found Adobe apllication" 174 strVersion = vbNullString 175 Exit Function 176 End If 177 178 'アプリのフルパスを出力 179 strPath = Left$(strPath, InStr(strPath, ".exe") + 3) 180 181 'ハンドルを閉じる 182 Call RegCloseKey(InstallPathReg) 183 184 '*************************************************** 185 '取得したパスの exeファイル情報を取得する 186 '*************************************************** 187 188 Dim lngSizeOfVersionInfo As Long 189 Dim lngDummyHandle As Long 190 Dim bytDummyVersionInfo() As Byte 191 Dim lngPointerVersionInfo As Long 192 Dim lnglLengthVersionInfo As Long 193 Dim udtVSFixedFileInfo As VS_FIXEDFILEINFO 194 195 'バージョン情報のサイズを取得 196 lngSizeOfVersionInfo = GetFileVersionInfoSize(strPath, _ 197 lngDummyHandle) 198 199 'ダミー変数の領域を確保 200 ReDim bytDummyVersionInfo(lngSizeOfVersionInfo - 1) 201 202 'バージョン情報を取得 203 lRet = GetFileVersionInfo(strPath, 0, _ 204 lngSizeOfVersionInfo, bytDummyVersionInfo(0)) 205 206 'バージョン情報リソースのルートブロックを取得 207 lRet = VerQueryValue(bytDummyVersionInfo(0), "¥", _ 208 lngPointerVersionInfo, lnglLengthVersionInfo) 209 210 '取得したルートブロックをバージョン情報の構造体へ移動 211 MoveMemory udtVSFixedFileInfo, _ 212 ByVal lngPointerVersionInfo, Len(udtVSFixedFileInfo) 213 214 With udtVSFixedFileInfo 215 'ファイルバージョンを取り出し 216 strFileVersion = _ 217 CStr((.dwFileVersionMS ¥ 2 ^ 16) And &HFFFF&) & "." & _ 218 CStr(.dwFileVersionMS And &HFFFF&) & "." & _ 219 CStr((.dwFileVersionLS ¥ 2 ^ 16) And &HFFFF&) & "." & _ 220 CStr(.dwFileVersionLS And &HFFFF&) 221 222 '製品バージョンを取り出し 223 strProductVersion = _ 224 CStr((.dwProductVersionMS ¥ 2 ^ 16) And &HFFFF&) & "." & _ 225 CStr(.dwProductVersionMS And &HFFFF&) & "." & _ 226 CStr((.dwProductVersionLS ¥ 2 ^ 16) And &HFFFF&) & "." & _ 227 CStr(.dwProductVersionLS And &HFFFF&) 228 229 strVersion = CStr((.dwProductVersionMS ¥ 2 ^ 16) And &HFFFF&) 230 231 End With 232 233 '確認 234 ' Debug.Print "strFileVersion =" & strFileVersion 235 ' Debug.Print "strProductVersion=" & strProductVersion 236 237 Get_Adobe_App_Info_nnn2 = True 238 Exit Function 239 240 Err_Get_Adobe_App_Info_nnn2: 241 strMsg = "Run Time Error" & vbCrLf & Err.Number & _ 242 vbCrLf & Err.Description 243 Get_Adobe_App_Info_nnn2 = False 244 End Function


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

備考

  1. 以下のサイトのサンプルを元に作成しました
    http://helpx.adobe.com/jp/acrobat/kb/511265.html

ご注意

当サンプルは製品バージョンの情報がファイルバージョンの情報と同じ値を取得するバグ?が有ります。

製品バージョンを取得したい方はコチラ「外部のDLLやEXEファイルのバージョン情報を取得(VB6.0) ( No.0 ) 」のサンプルを参考にしてください。動作確認したところ、正常に製品バージョンを取得できました。

動作確認環境

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

サンプル一覧


管理者だけのメモ

以下は見なくても結構です。

テスト結果のメモです。

テスト結果

動作確認環境: Windows XP 32bit + Office 2003 Excel

・Adobe Acrobat 5  (5.0.5) (32b XP)
strFileVersion   =5.0.5.452
strProductVersion=5.0.0.0
AcrobatPath    ='C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe'
Acrobat Version='5'
Message        ='ファイルバージョンと製品バージョンが異なる'

・Adobe Acrobat 6 Professional (6.0.6)
strFileVersion   =6.0.5.399
strProductVersion=6.0.5.399
AcrobatPath    ='C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe'
Acrobat Version='6'
Message        =''

・Adobe Acrobat 7 Professional (7.1.4)
strFileVersion   =7.0.8.218
strProductVersion=7.0.8.218
AcrobatPath    ='C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe'
Acrobat Version='7'
Message        =''

・Adobe Acrobat 8 Professional (8.3.1)
※OS: Windows 7 64bit + Office 2007 Excel
strFileVersion   =8.3.1.289
strProductVersion=8.3.1.289
AcrobatPath    ='C:\Program Files (x86)\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe'
Acrobat Version='8'
Message        =''

・Adobe Acrobat 9 Pro Extended (9.5.2)
strFileVersion   =9.5.2.295
strProductVersion=9.5.2.295
AcrobatPath    ='C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe'
Acrobat Version='9'
Message        =''

・Adobe Acrobat X Pro (10.1.4)
strFileVersion   =10.1.4.38
strProductVersion=10.1.4.38
AcrobatPath    ='C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe'
Acrobat Version='10'
Message        =''

・Adobe Acrobat XI Pro (10.0.4)
strFileVersion   =11.0.4.63
strProductVersion=11.0.4.63
AcrobatPath    ='C:\Program Files\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe'
Acrobat Version='11'
Message        =''

サンプル一覧

「関数:Acrobat , Adobe Reader のインストールパスとバージョンを取得」への2件のフィードバック

  1. 関数:PDFを特定のフォーマットに変換する
    をこちらの環境で試したところ、バージョンが17になっており、
    先に進めません。

    デバッグしているのですが、変換パラメータや出力時のデフォルト拡張子の記述部分はどこから持ってくるのか、ご教示いただけませんでしょうか。

    ちなみに、Acrobat 2017です。

  2. 須田 さん はじめまして。

    当ページは「関数:Acrobat , Adobe Reader のインストールパスとバージョンを取得」①に関する内容で、「関数:PDFを特定のフォーマットに変換する」②は別ページですから、質問はこのページ?
    いやいや、コッチ「関数:PDFを特定のフォーマットに変換する」のページですかね?

    >関数:PDFを特定のフォーマットに変換する

    まず、上記の関数はAcrobat XI (version 11)までを想定しています。

    >をこちらの環境で試したところ、バージョンが17になっており、
    >先に進めません。

    ②のページ上でのエラーなら
    If Not (CLng(strAcrobatVersion) >= 8 And CLng(strAcrobatVersion) <= 11)

    If Not (CLng(strAcrobatVersion) >= 8 And CLng(strAcrobatVersion) <= 17)
    にしたら動くかもしれませんが、・・。
    新バージョン Acrobat 2017 の登場はこの場で初めて知りました。
    よって動作確認環境も無いので結果は保証できません。

    >デバッグしているのですが、変換パラメータや出力時のデフォルト
    >拡張子の記述部分はどこから持ってくるのか、・・

    この質問は②の方ですね。
    これは 「関数:PDFを特定のフォーマットに変換する」 の引数に書いてあります。
    それだけでは分かりにくいので「Sub Convert_PDF_Format_Main_TEST()」にも引数のサンプルを書いてあります。それを参考にして下さい。

    *第2引数 ( string strOutputFolder ) : (IN)
    *変換先のフォルダ名
    *既に存在する必要が有る。無いとエラーになる。
    strOutputFolder = "I:¥Adobe PDF¥Output"

    *変換元のPDFのフルパス (IN/必須)
    strConvPDFfile(0, 0) = "I:¥Adobe PDF¥TEST-NO-Sec.pdf"
    *変換タイプ (IN/必須)
    strConvPDFfile(0, 1) = "accesstext" '変換タイプ
    * 変換先ファイル名 (IN/任意)
    strConvPDFfile(0, 2) = "TEST-NO-Sec.txt" '出力ファイル名
    *処理結果 エラーメッセージをセット(OUT)
    strConvPDFfile(0, 3) = "" '処理結果
    strConvPDFfile(1, 0) = "I:¥Adobe PDF¥TEST-NO-Sec.pdf"
    strConvPDFfile(1, 1) = "doc" '変換タイプ
    strConvPDFfile(1, 2) = "TEST-NO-Sec.doc" '出力ファイル名
    strConvPDFfile(1, 3) = "" '処理結果
    strConvPDFfile(2, 0) = "I:¥Adobe PDF¥VBJavaScript.pdf"
    strConvPDFfile(2, 1) = "eps" '変換タイプ
    strConvPDFfile(2, 2) = "" '未指定はVBJavaScript.epsになる
    strConvPDFfile(2, 3) = "" '処理結果

    accesstext、doc、epsの拡張子は②の概要に書いて有ります。(分かりにくかったですかね、汗。)
    拡張子は ExportTask.xml から持ってきています。
    但し、ExportTask.xmlに関してはAdobe社からの一般公開情報には明記が見当たりません。海外のサイトを調べても全く有りません。これは当サイトが独自に調査してテストから出した結果です。

    なお、ファイル変換を行うのでしたら、他にも「サンプル/関数 一覧」にサンプルが有ります。

    それと途中でも書きましたが、Acrobat 2017 は初めて知りました。どのような動作をするのか、全く予想が出来ません。

    以上、返答させて頂きます。
    ※スイマセン。急いで返答したので乱文です。(疲

    ▼追加 2017/7/6 8:42
    4年も前の事なので記憶が薄れていますが。拡張子に関する情報は一般公開されていませんでした。偶然 Acrobat JavaScript で同様なフォーマット変換時に変換ID(例:com.adobe.acrobat.xml-1-00)を使っている事を知りました。これをレジストリを含めWindowsシステム全体で検索したところ、ExportTask.xmlに行き着きました。そこから一致する変換時の拡張子を取り出しました。それが「関数:PDFを特定のフォーマットに変換する」の概要の最初の部分に書いてある拡張子です。くどいようですが、この情報に関しては他のネット上に存在しません。

    ▼追加 2017/7/6 9:17
    かなり思い出して来ました。Acrobat OLEでも拡張子の指定は出来なく、変換IDを使う必要があります。そこでExportTask.xmlの内容から拡張子に該当すると思われる変換IDを決定しています。
    よって修正する箇所は「関数:PDFを特定のフォーマットに変換する」サンプルのConvert_PDF_Format_ET_nnn2 関数内の
    If Not (CLng(strAcrobatVersion) >= 8 And CLng(strAcrobatVersion) <= 11)

    If Not (CLng(strAcrobatVersion) >= 8 And CLng(strAcrobatVersion) <= 17)
    に、更に
    Case "11"

    Case "11","17"
    で動くかもしれないです。
    Acrobat 2017環境が無いので動作未確認です。

コメントを残す

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

CAPTCHA


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


SAMURAI Plugin

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

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



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

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