Applescript set character inserting multiple letters

I have a script that opens an Excel spreadsheet and loops through theCell. The character count for the first cell is 17 (theChrCount) and the contents of the cell (theCellValue) is “Application Files”. When I run the script through the first loop, character 1 shows as “A”. When I run through the second loop, character 2 shows “pp”. The third shows character 3 as “pli” and so on. So the 6th character shows 6 values. Any idea why character 2 would show “pl” instead of “p”? It’s like character n is the character at n for n places. This script ran well under the old version of Excel but stopped working on Microsoft Excel for Mac Version 15.33.

                                set theCell to cell ("F" & i)
                                set theCellValue to value of theCell as string
                                set theChrCount to (get count of characters in theCellValue)

                                repeat with n from 1 to theChrCount --> 0.79s
                                          
                                            set theChr to character n of theCell
                                            set theChrProp to properties of theChr
                                            set theFontObject to font object of theChrProp
                                          
                                end repeat

Model: MacBook Pro
AppleScript: 2.5
Browser: Safari 602.1.50
Operating System: Mac OS X (10.10)

What does the dictionary say about character? When I run the code in Excell 2011 everything works fine as expected. I created a new document in Excel and filled cell A1 with “Application Files” and ran the code below:

tell application "Microsoft Excel"
	tell active workbook
		tell active sheet
			set theCell to cell "A1"
			set theCellValue to value of theCell as string
			set theChrCount to (get count of characters in theCellValue)
			
			repeat with n from 1 to theChrCount
				
				set theChr to character n of theCell
				display dialog (content of theChr as string)
				set theChrProp to properties of theChr
				set theFontObject to font object of theChrProp
				
			end repeat
		end tell
	end tell
end tell

I’m trying to upload a link of my screenshot. In the meantime, this is what Character says in dictionary:
character
character (noun), pl charactersRepresents characters in an object that contains text.
properties
Property
Access
Type
Description
content get/set text Returns or sets the text for the specified object.
font object get font Returns a font object that represents the font of the specified object.
phonetic characters get/set text Returns or sets the phonetic text in the specified characters object.
where used
The character class is used in the following ways:
element of groupbox class
element of label class
element of option button class
direct parameter to the insert into command/event
element of text frame class
element of row class
element of axis title class
element of chart title class
element of data label class
element of display unit label class
element of textbox class
element of arc class
element of oval class
element of rectangle class
element of button class
element of checkbox class
element of cell class
element of column class
element of range class
element of dropdown class

Here is a screen shot of the values. Note that Character 1 is an “A” and bold/italic which is correct. Character 2 is “pp” and false for bold but the first p IS bold.

http://www.necomp.us/pics/theCells.png

What I’m trying to accomplish is getting any bold or italic characters and, in cell “O” putting something like 1123, where the first character is bold and italic, the second is bold, and the third is just italic. When I look at charcter 2, it is seeing “pp” instead of “p” and it is not recognizing it as bold.

What if you don’t start from 1 but you start from position 4 with the for loop? So the first loop you start at position 4 (repeat with n from 4 to theChrCount). And what happens when you reverse the loop (repeat with n from theChrCount to 1 by -1)?

It seems like a bug with the cell’s internal pointer but I don’t want to jump to any conclusions too soon.

I put a breakpoint before the loop even starts. If you look at the screenshot, you can see that the second character of theCell is “pp” instead of p. BTW: I just tried starting the loop at 4 and it shows character 4 as “lica” which is the fourth charcter for 4 characters.

I’ll try contacting Microsoft but I won’t hold my breath waiting for a response.

Model: MacBook Pro
AppleScript: 2.5
Browser: Safari 602.1.50
Operating System: Mac OS X (10.10)