The information in this article applies to:
SYMPTOMS
When you upgrade to one of the Microsoft Excel versions listed at the
beginning of this article from Microsoft Excel version 5.0 for Windows (a
16-bit application), you may have trouble running macros that you created
in the previous version of Microsoft Excel. This includes macros written in
the Microsoft Excel macro language (XLM), as well as macros written in the
Visual Basic for Applications language.
-or-
- or -
CAUSE
This problem occurs when you run a macro in a 32-bit version of Microsoft
Excel that calls a 16-bit Windows application programming interface (API)
or 16-bit Windows dynamic-link library (DLL). For example, if you create a
Visual Basic macro in Microsoft Excel version 5.0 for Windows that calls a
16-bit DLL, the macro may return an error message or may not run at all in
Microsoft Excel for Windows 95.
ExampleIf you run the following macro in 32-bit version of Microsoft Excel, you receive one of the following error messages:
-or-
This error message occurs because the code in your macro calls a 16-bit DLL
that cannot be loaded in a 32-bit version of Microsoft Excel. If you modify
the DECLARE statement in the above example to call "KERNEL32" instead of
"KERNEL," you will receive one of the following error messages when you run
the example in a 32-bit version of Microsoft Excel:
-or- This error message may occur in other cases when you modify a 16-bit macro to run in a 32-bit version of Microsoft Excel, because some API functions may be located in different libraries. RESOLUTION
NOTE: It may be possible to work around this situation by creating a macro
that makes calls to the Windows application programming interface (API).
This type of programming is supported by the Windows Software Development
Kit (SDK) and the Visual Basic, Professional Edition, support groups. The
level of support you can receive from these groups depends on the
individual support policies of the group. (Microsoft Support professionals may
not be able to assist in specific construction of macros that use API
programming.) If you have limited programming experience, you may want to
consult one of the Microsoft Solution Providers. Solution Providers offer a
wide range of fee-based services, including creating custom macros. For
more information about Microsoft Solution Providers, call Microsoft
Customer Information Service at (800) 426-9400.
To modify macros you created in Microsoft Excel version 5.0 for Windows,
you must modify your code to make Win32 API calls when you run the macro in
a 32-bit version of Microsoft Excel. If this is not possible (for example,
if you don't have access to the source code of the DLL), you must modify
the macro to "thunk" through an intermediate DLL to make the 16-bit API
call.
Visual Basic ExampleMicrosoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft Product Support Services (PSS) professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.In the following example, the macro checks to see if 32-bit Windows is present and uses the appropriate API call for 16-Bit or 32-Bit Windows, whichever is detected. Note that this example does not check for the version of Microsoft Excel. The macro assumes that you are either running a 16-bit version of Microsoft Excel under a 16-bit version of Windows, or a 32-bit version of Microsoft Excel under a 32-bit version of Windows. NOTE: The first two lines (the DECLARE statements) should be placed at the top of a module sheet, outside of any other subs or functions in the module.
MORE INFORMATIONMicrosoft Excel for Windows NT Xlreadme.hlpFor more information about running 16-bit DLLs or XLLs in Microsoft Excel for Windows NT, do the following:
Office-Based Solutions to 32-Bit OfficeChapter 12 of the Office Resource Kit (beginning on page 360), titled "Support and Troubleshooting," describes how to port your 16-bit Microsoft Office solutions to 32-bit Office. This chapter discusses 16- to-32-bit API issues you may need to handle. To access this information in the Office Resource Kit, run the Ork.exe file located in the Orkchapt folder on the Office Resource Kit compact disc. Chapter 12 in the Office Resource Kit contains the following sections for additional information:
Q140619 Contents of the MS Office for Windows 95 Resource Kit For additional information about a similar problem in Microsoft Word, please see the following article in the Microsoft Knowledge Base: Q120767 Porting 16-Bit WordBasic Macros to 32-Bit WordBasic Macros Additional query words: 16 bit 32 16bit 32bit
Keywords : kbcode kbprg |
Last Reviewed: November 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |