Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Automation Formatting and F9
Message
From
14/01/2009 09:31:39
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Novell 6.x
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01372023
Message ID:
01373538
Views:
23
The condition I have is that these fields are text (because I don't want to drop leading zeros). I have seen the same thing happen when you don't alltrim the text field before you convert to excel, but when you remove all excess spaces from the column the format usually kicks in. In this case it does not. Only one by one as you click in the = box then out.

>Hi Yuri,
>
>Reading these notes it seems to me that the problem you were trying to solve was the opposite, e.g. numbers were treated not as real numbers by Excel.
>
>For me Kevin's case looks like text fields were treated by Excel as numbers rather than text. Do you have ideas on this problem?
>
>>>I am doing some Excel Automation and I extract out a table, then I do some formatting to some of the columns. I replace the values of the tables with an alltrim on the value from the main table to make sure there are no spaces to mess up the formatting. Some formatting are like a social as ###-##-#### and Phone as (###)###-####. The formatting gets set properly, but it does not show correctly on the excel sheet result. If you click on one of the values and click the cursor on the value in the = box then click somewhere else, it updates the cell showing that value with the correct formatting, but only that cell. If I highlight the whole column and hit F9, it still does not show the values with the correct formatting. Any ideas?
>>
>>From what you described I cannot get exact details, but I experienced similar problem
>>when the number is stored in Excel cell with asterisk in front of it. Then Excel recognizes it as a number,
>>you may perform math operation, etc, but there are problems with cell formatting as you described.
>>Here are my notes of how Excel recommended resolving it (I remember I couldn't stop laughing, but
>>until now I do not know any other approach):
>>
>>
>>*nothing works, except as recommended in Excel Help: (MULTIPLY by 1, ???? !!!)
>>*Convert numbers stored as text to numbers
>>*In an empty cell, enter the number 1. 
>>*Select the cell, and on the Edit menu, click Copy. 
>>*Select the range of numbers stored as text you want to convert. 
>>*On the Edit menu, click Paste Special. 
>>*Under Operation, click Multiply. 
>>*Click OK. 
>>*Delete the content of the cell entered in the first step. 
>>
>>*Note   Some accounting programs display negative values with the negative sign (–) to the right of the value. 
>>* To convert the text strings *to values, you must return all of the characters of the text string except the rightmost character 
>>* (the negation sign), and then multiply *the result by –1. For example, if the value in cell A2 is "156–" the following 
>>* formula converts the text to the value –156.
>>
>>*Example:
>>
>>ia=oExcel.activesheet.usedrange.Columns.count+1
>>WITH oExcel.activesheet.cells(1,ia)
>>	.value=1
>>	.copy
>>ENDWITH
>>xlPasteAll=-4104
>>xlMultiply=4
>>WITH oExcel.activesheet.usedrange
>>	.Columns(2).PasteSpecial(xlPasteAll, xlMultiply)
>>ENDWITH
>>
>>
>>
>>Good Luck
``` Appreciate a normal day, it is always better than a bad one ```

Kev
Previous
Reply
Map
View

Click here to load this message in the networking platform