Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Automation Formatting and F9
Message
 
To
08/01/2009 09:01:22
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:
01372058
Views:
28
>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, ???? !!!, and then apply formatting again)
*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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform