MXL: How to Use the MacID Function

Last reviewed: February 2, 1998
Article ID: Q138822
The information in this article applies to:
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for the Power Macintosh, version 5.0, 5.0a
  • Microsoft Excel 98 Macintosh Edition

SUMMARY

The Visual Basic for Applications MacID function is unique to the Macintosh platform and can be used when you use the Kill, Shell, Dir, and AppActivate functions. Because the Macintosh does not support wild cards, you can instead use the MacID function to specify the file type of a group of files.

MORE INFORMATION

The following macro code examples use the MacID function, as well as the equivalent Microsoft Excel for Windows code.

Note, in each of the four examples below, the argument for the MacID function should be a text string (note that this string is case sensitive). Also, you may want to rebuild your desktop if the MacID function does not work as you expect.

For more information about Rebuilding the Desktop, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q82980
   TITLE     : Excel: Unexpected Quit Under Macintosh System 7.0.x

Kill Statement

   Macintosh          Kill MacID("TEXT")
   Windows            Kill "*.txt"

This will delete all text files in the current directory.

Dir Function

   Macintosh          myfile = Dir("HD:MyFolder:", MacID("XLS5"))
   Windows            myfile = Dir("c:\mydir\*.xls")

This will return the name of the first Microsoft Excel file in the specified folder to the variable "myfile." Note that in the Macintosh example, you need to follow the specified folder with a colon.

Shell Function

   Macintosh          myprog = Shell(MacID("MSWD"))
   Windows            myprog = Shell("C:\Msoffice\Winword\Winword.exe")

This will start Microsoft Word from within your Microsoft Excel macro, and in the Windows example, assumes that Microsoft Word is in the C:\Msoffice\Winword folder. If the Shell function successfully runs the named file, it returns the task identification (ID) of the started program to the variable "myprog". The task ID is a unique number that identifies the running program.

AppActivate Statement

   Macintosh          AppActivate MacID("MSWD")
   Windows            AppActivate "Microsoft Word"

This will activate Microsoft Word from within you Microsoft Excel macro. NOTE: In order for the AppActivate Statement to work, you must first have the application started.

REFERENCES

For more information about the MacID Function, click the Index tab in Microsoft Excel Help, type the following text

   macid

and then double-click the selected text.


Additional query words: 5.00 5.00a 98 XL98 XL5 Mac ID
Keywords : xlmac
Version : MACINTOSH:5.0,5.0a,98
Platform : MACINTOSH
Issue type : kbhowto kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.