Excel・非表示モジュール内でコンパイルエラーが発生しました(Compilation error in hidden module)

※全てのExcelで動作する保証はありません。また、内容に関し管理人は全ての責任を負いかねます

* There is no guarantee that it will work with all Excel. In addition, the administrator does not take any responsibility for the content.

Excelメニューへ戻る Back to Excel menu

 

旧タイトル old title

マクロを含む古いエクセルファイルをExcel2019でエラーに

Error in old excel file with macros in excel2019

 

対象 subject

マクロを含むエクセルファイル(Excel文書、エクセルブック)で、かつ、古い形式の互換ファイル。

拡張子が xls のものが対象で、xls以外のファイルは検証していません。

この記事では以下「マクロ有りの互換ファイル(xls)」と呼びます。

Excel files (Excel documents, Excel workbooks) that contain macros and are old-format compatible files.

The extension is xls, and files other than xls are not verified.

In this article, it is called “compatible file with macros (xls)”.

 

症状 symptoms

「マクロ有りの互換ファイル(xls)」をExcel2019(Office2019)で開いたら、エラーが発生しマクロが動作しなかった。

When I opened a “compatible file with macros (xls)” in Excel 2019 (Office 2019), an error occurred and the macros did not work.

 

症状は全てのファイルか? Are the symptoms all files?

私は「マクロ有りの互換ファイル(xls)」が複数所有していますが、症状が出たの1つだけでした。ですので、「マクロ有りの互換ファイル(xls)だと必ずエラーが出る」というわけではありません。

I have multiple “compatible files with macros (xls)”, but only one symptom appeared. Therefore, it does not mean that “compatible file (xls) with macros always causes an error”.

 

エラーの内容(画像) Content of the error(Image)

「Microsoft Visual Basic for Applications 非表示モジュール内でコンパイルエラーが発生しました。通常このエラーは、コードがこのアプリケーションのバージョン、プラットフ」

「Microsoft Visual Basic for Applications 非表示モジュール内でコンパイルエラーが発生しました。通常このエラーは、コードがこのアプリケーションのバージョン、プラットフ」

“A compile error occurred within a Microsoft Visual Basic for Applications hidden module. This error is usually caused by code differences in this application version, platform”

 

特定のコード、関数か? Specific code, function?

現時点では「特定のコードではない」と判断しています。その理由は、問題のモジュールでエラーが出て中断しても、毎回、中断する場所が異なるからです。

At this time, we have determined that it is not a specific code.

The reason is that even if an error occurs in the module and an interrupt occurs, the interrupt location is different each time.

 

考えられる原因 Possible cause

ネット上の情報から、Excel2019からマイクロソフト社は 64bit にしたため。Excel2016以前は基本的に 32bit だったので、コードの一部で非互換が発生している模様。(意図的に64bit版Excelを入れた場合は除く)

補足ですが「私のマクロ有りの互換ファイル(.xls)」が古すぎるので、非互換のエラーが出ても仕方がないと判断しています。(現在は「Excelマクロ有効ブック(*.xlsm)」が一般的です。)

According to internet information, Microsoft changed from Excel 2019 to 64bit.Since Excel 2016 and earlier were basically 32bit, there seems to be some incompatibilities in the code.(Unless you intentionally installed a 64-bit version of Excel)

As a postscript, “My substitute file with macros (.xls)” is too old, so I’ve decided that it can’t be helped if an incompatibility error appears.(Currently, “Excel macro-enabled workbook (*.xlsm)” is common.)

 

回避策 Workaround

検証の前にファイルをバックアップしてから、この回避策を試されることを強くお勧めします。

Before trying this workaround, we strongly recommend backing up your files before testing.

 

手順

1. 「マクロ有りの互換ファイル(xls)」を Excel2010/2013/2016 のいずれかで開く

2. 「コンテンツの有効化」をクリック

3. 上書き保存する

4. 問題のファイルをExcel2019のパソコンにコピーして開く

5. 以上の結果、エラーが出ず、正常にマクロが動作しました。

 

procedure

1. Open “compatible file with macro (xls)” in Excel 2010/2013/2016.

2. Click “Enable Content”.

3. Overwrite save.

4. Copy the file in question to your PC in Excel 2019 and open it.

5. As a result of the above, the macro ran successfully without any errors.

 

その回避策のメリットは? What are the benefits of that workaround?

・コードを変更する必要がない点です。

・No need to change the code.

・「マクロ有りの互換ファイル(xls)」が、Excel2016までは問題なく開いていたのにExcel2019でエラーで開かないとお困りの場合、とりあえずファイルを開くことができる点です。

・If Excel 2019 could not open “compatible file with macro (xls)” due to an error even though it was opened without problems up to Excel 2016, you can open the file for now.

 

[PR] Amazon.co.jpで ExcelのVBA の本を探す

疑問 question

Q. 回避策を実施すると、なぜエラーが出ないのか?

A. 不明です。

Q.Why does the error not occur after implementing the workaround?

A. I don’t know.

 

他にわかっていること What else do we know

・「マクロ有りの互換ファイル(xls)」を、マクロ有効ブック(xlsm)として別名保存しても同じようにエラーになる。これはExcelのどのバージョンでも同じ。

・The same error occurs even if you save “macro-enabled file (xls)” as a macro-enabled workbook (xlsm) with a different name. This is the same for any version of Excel.

 

・Excel2007で「マクロ有りの互換ファイル(xls)」を開いて保存したものを、Excel2019で開くとエラーになる。

・I get an error when opening and saving a “compatible file with macros (xls)” in Excel 2007 and opening it in Excel 2019.

 

・「マクロ有りの互換ファイル(xls)」を何もせずに、そのままExcel2019で開くとエラーになる。

したがって、2019ではない他のExcel(2010/2013/2016)で一度保存する必要がある、と判断しました。

・If you open “compatible file with macro (xls)” as it is in Excel 2019, an error will occur.

Therefore, I decided that it is necessary to save once in another Excel (2010/2013/2016) that is not 2019.

 

Excelメニューへ戻る Back to Excel menu

16

ほかの エクセル の記事

[Excel][VBA]エラーになった事例集

Excelメニュー

[Excel][操作]一気に先頭行、先頭列に戻る

[Excel][VBA]型変換

[Excel]2ページではなく1ページで印刷したい

Ads Blocker Image Powered by Code Help Pro

誤表示の場合はおゆるし下さい。[更新]をタップして下さい。

この記事のQRコード
このサイトのQRコード