XL: DefType Statements Change If Workbook Used on New Platform

ID: Q134412

The information in this article applies to:

SYMPTOMS

In the versions of Microsoft Excel listed above, when you transfer a Microsoft Excel workbook from the Windows platform to the Macintosh platform, or vice versa, any DefType statements that are contained within a Visual Basic module in the workbook may be changed arbitrarily or may disappear completely.

WORKAROUND

To avoid this problem, use apostrophes to comment out any DefType statements in your code before you transfer the workbook to a different platform (Windows or Macintosh). Once the file has been transferred, you can remove the apostrophes from the DefType statements, and your code should behave as expected.

For more information about comments in Visual Basic Code, click the Index tab in Microsoft Excel Help, type the following text

   Comments, Visual

double-click the selected text, and then click Colors And Capitalization.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition.

MORE INFORMATION

Microsoft Excel includes the following DefType statements:

   DefBool   DefInt    DefLng   DefCur   DefSng
   DefDbl    DefDate   DefStr   DefObj   DefVar

DefType statements are used to declare that all variables whose names begin with a certain letter (or letters) are of a certain type. For example, this statement

   DefBool A

declares that all variables whose names begin with the letter "A" or "a" are Boolean variables, unless they are explicitly declared otherwise.

If you transfer a workbook that contains such statements from the Windows platform to the Macintosh platform, or vice versa, DefType statements contained in the workbook may change arbitrarily or may disappear completely. For example, if you create a workbook in Microsoft Excel for Windows that contains the DefType statements shown in the left column of the following table, and you then transfer that file to Microsoft Excel for the Macintosh, the DefType statements will probably resemble those statements shown in the right column of the table:

   Original platform         New platform
   --------------------------------------

   DefBool A                 DefBool Q
   DefInt B                  DefInt R
   DefLng C                  DefLng S
   DefCur D                  DefCur T
   DefSng E                  DefSng U
   DefDbl F                  DefDbl V
   DefDate G                 DefDate W
   DefStr H                  DefStr X
   DefObj I                  DefObj Y
   DefVar J                  DebVar Z

   DefBool K
   DefInt L
   DefLng M
   DefCur N
   DefSng O
   DefDbl P

   DefDate Q                 DefDate A
   DefStr R                  DefStr B
   DefObj S                  DefObj C
   DefVar T                  DefVar D
   DefBool U                 DefBool E
   DefInt V                  DefInt F
   DefLng W                  DefLng G
   DefCur X                  DefCur H
   DefSng Y                  DefSng I
   DefDbl Z                  DefDbl J

Some DefType statements are changed to refer to a different letter, while others disappear completely. This may prevent code in your workbook from being executed correctly.

The results are the same whether you transfer a workbook from the Windows platform to the Macintosh platform or from the Macintosh platform to the Windows platform.

Additional query words: 7.00 5.00 5.00a 5.00c 7.00 XL7 XL5 integer long currency single double date string object variant arbitrary arbitrarily copy

Keywords          : kbenv kbprg PgmOthr 
Version           : WINDOWS:5.0,5.0c,7.0; MACINTOSH:5.0,5.0a
Platform          : MACINTOSH WINDOWS
Issue type        : kbbug
Solution Type     : kbfix

Last Reviewed: February 4, 1998