Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Problems Using Recorded Macro That Creates Map Object


View products that this article applies to.

This article was previously published under Q213787

↑ Back to the top


Symptoms

When you record and then run a macro that embeds a Microsoft Map object in a worksheet, the position and size of the map may differ from the map that you created when you recorded the macro.

↑ Back to the top


Workaround

Microsoft provides programming examples 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. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
To work around this problem, modify the macro to set the proper coordinates for the map object. The following steps illustrate how to record and modify a macro that embeds a Microsoft Map object on your worksheet.

NOTE: If you have not already done so, add the Map button to a custom toolbar.

Add the Map Button to a Toolbar

  1. Show the toolbar that you want to add the Map button to.
  2. On the Tools menu, click Customize, and then click the Commands tab.
  3. In the Categories list, click Insert.
  4. Drag Map from the Commands list to the toolbar that you want.

Recording the Macro

  1. In Microsoft Excel, open a new workbook.
  2. In cells A1:B1 on Sheet1, type the following:
          A1: Mexico     B1: 100
    					
  3. On the Tools menu, point to Macro, and then click Record New Macro.
  4. Type CreateMap in the Macro name box, and then click OK to start recording.
  5. Select cells A1:B1.
  6. Click the Map button on the toolbar, and then draw the map on Sheet1.

    NOTE: If you get the following error message:
    The Microsoft Map data file EUROPE.IND was not found.
    click OK, and the Multiple Maps Available dialog box will appear.
  7. If the Multiple Maps Available dialog box appears, select a map, and then click OK.
  8. Select cell A1 on the worksheet to deactivate the map object.
  9. On the Tools menu, point to Macro, and then click Stop Recording.

Modifying the Macro

  1. On the Tools menu, point to Macro, and then click Macros.
  2. Select the CreateMap macro, and then click Edit. The CreateMap macro appears in the Code window in the Visual Basic Editor. It will look similar to the following example:
    Sub CreateMap()
    
       Range("A1:B2").Select
       Range("B2").Activate
       ActiveSheet.OLEObjects.Add(ClassType:="MSMap.8", Link:=False, _
          DisplayAsIcon:=False, Left:=3.75, Top:=9, Width:=3.75, _
          Height:=9).Activate
       Application.CutCopyMode = False
       Range("A1").Select
    End Sub
    					
  3. Modify the macro to look like the following example:
    Sub CreateMap()
    
       Range("A1:B2").Select
       Range("B2").Activate
       ActiveSheet.OLEObjects.Add(ClassType:="MSMap.8", Link:=False, _
          DisplayAsIcon:=False, Left:=50, Top:=50, Width:=200, _
          Height:=160).Activate
       Range("A1").Select
    End Sub
    						
    Notice that you change the arguments for the Add method for the OLEObjects collection to indicate the coordinates and size of the data map. You do not need to remove the Application.CutCopyMode = False line.
  4. On the File menu, click Close and Return to Microsoft Excel.
To run the macro, on Sheet1, point to Macro on the Tools menu, click Macros, select the macro CreateMap, and then click Run.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in Microsoft Excel 2000.

↑ Back to the top


References

For additional information about the error message mentioned in this article, click the article number below to view the article in the Microsoft Knowledge Base:
235306� XL2000: The Microsoft Map data file EUROPE.IND was not found.

↑ Back to the top


Keywords: KB213787, kbprogramming, kbpending, kbdtacode, kbbug

↑ Back to the top

Article Info
Article ID : 213787
Revision : 8
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 276