Microsoft KB Archive/186765

= General Alignment Applied Differently to WK3 Files in XL5 =

Article ID: 186765

Article Last Modified on 8/17/2005

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition

-



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:

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

A1: Left

A2: General

 Select cell A1. On the Format menu, click Cells. Click the Alignment tab on the Format cells dialog box. Under Horizontal, click Left. Click OK. 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. 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.</li> On the Insert menu, point to Macro, and then click Module.</li>  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 </li> 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.</li> Close the test.wk3 workbook and do not save the changes.</li> Open test.wk3 in Excel 7.</li> Select A1. On the Format menu, click Cells.</li> Click the Alignment tab on the Format cells dialog box. Under Horizontal, click Left. Click OK.</li> Repeat steps 7 through 9.</li></ol>

In Microsoft Excel 7 and Excel 97, the first message box returns True; the second returns False.

<div class="references_section">