General Alignment Applied Differently to WK3 Files in XL5 (186765)



The information in this article applies to:

  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95
  • Microsoft Excel for Windows 5.0

This article was previously published under Q186765

SYMPTOMS

When you open a file that was saved in the Lotus 1-2-3(.wk3) format in Microsoft Excel 7.0 or Microsoft Excel 97, a Microsoft Visual Basic for Applications subroutine may return False when you try to programatically determine whether the values in a cell are left aligned. In Microsoft Excel 5.0, the same subroutine returns True.

To see an example of this problem, please see the "More Information" section of this article.

CAUSE

This problem may occur when the cells are formatted with the General format. In Excel 5.0, if the cell uses the General format, your subroutine returns True if you test for left alignment. However, in Excel 7.0 or Excel 97, the same subroutine returns False if the cells use the General format.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.

Example of the problem

To see an example of the problem, follow these steps:

  1. Start Microsoft Excel 5.0.
  2. Type the following into a new workbook:

    A1: Left
    A2: General

  3. Select cell A1. On the Format menu, click Cells.
  4. Click the Alignment tab on the Format cells dialog box. Under Horizontal, click Left. Click OK.
  5. On the File menu, click Save As. In the File Name box, type test. In the Save File as Type list, click WK3 (1-2-3). Click OK. Click OK again when the Summary Info dialog box appears.
  6. On the File menu, click Close. Click No when you are prompted to save the file in the Microsoft Excel format. On the File menu, click Test.WK3.
  7. On the Insert menu, point to Macro, and then click Module.
  8. Type the following Visual Basic subroutine into the new module sheet:
           Sub Test()
    
              Msgbox(Worksheets(1).Range("A1").Horizontalalignment = xlLeft)
              Msgbox(Worksheets(1).Range("A2").Horizontalalignment = xlLeft)
    
           End Sub
    						
  9. Move the insertion point inside the subroutine. On the Run menu, click Start.

    Both message boxes return True even though cell A2 uses the General format.
  10. Close the test.wk3 workbook and do not save the changes.
  11. Open test.wk3 in Excel 7.
  12. Select A1. On the Format menu, click Cells.
  13. Click the Alignment tab on the Format cells dialog box. Under Horizontal, click Left. Click OK.
  14. Repeat steps 7 through 9.
In Microsoft Excel 7 and Excel 97, the first message box returns True; the second returns False.

REFERENCES

For more information about the alignment of cells, click Microsoft Excel Help Topics on the Help menu, click the Index tab in Microsoft Excel 7.0 Help, type the following text

aligning cell contents

and then double-click the selected text to go to the "Basic Formattting" topic.

Modification Type:MinorLast Reviewed:8/17/2005
Keywords:kbdtacode kbprb KB186765