Replace values in Quark 7 tables from excel sheet


is it possible to do the following with an AppleScript:

I have a excel sheet with these columns:
OrderNo., Price A, Price B

I have some QXP7 documents with different tables which look like this:
Col(1): OrderNo. | Col(2): Value1 | Col(3): Value2 | … Col(n-1): Value n-1 | Col(n): Price A

Now I need an apple script that goes through each table of my Quark document, and through each row of each table.
Whenever it finds an Order No. (formatted with a Character Style “OrderNo”) I want the script to search this order number in the excel list, then check if Price A in the qxd matches Price A in the excel sheet and then replace Price A in qxd by Price B from the excel sheet

Is this possible? Can anybody help me with programming such a script?

Thanks a lot for your help Smile


Model: MacPro
Browser: Firefox
Operating System: Mac OS X (10.4)

Maybe this is not possible with Quark 7 and Excel 2004?

It would be nice if anybody could help because it is urgent :slight_smile:

As it is one of my first scripts… (and until now it works :slight_smile: )

Could anyone please tell me what can be improved in this script.
Do you have to assume having crashes when I run this script?

Any ideas or help are welcome :slight_smile:


tell application "QuarkXPress Passport"
	set xEUR to "0.00"
	set xGBP to "0.00"	
	tell document 1		
		repeat with i from 1 to count of table boxes			
			tell table box i				
				set ccol to count of table columns
				set crow to count of table rows				
				repeat with j from 1 to count of generic cells					
					set acol to (((j - 1) mod ccol) + 1)
					set arow to (((j - 1) div ccol) + 1)					
					if acol = 1 or acol = ccol then
						if cell type of generic cell j is text cell type then
							tell story 1 of generic cell j
								set myCellText to first word of text 1
								set myCharStyle to name of character style
								if myCharStyle is "OrderNo" then
									--display dialog myCellText
									tell application "Microsoft Excel"
										tell worksheet 1 of workbook 1
											repeat with k from 1 to 130
												tell row k
													if value of cell 1 is myCellText then
														--display dialog myCellText & " found in Excel"
														set xEUR to value of cell 2
														set xGBP to value of cell 3
													end if
												end tell
											end repeat
										end tell
									end tell
									if first word of text 1 = xEUR then
										--display dialog "Value found"
										set first word of text 1 to xGBP
										if acol = ccol then
											set myword to first word of text 1
											set first word of text 1 to "!!" & myword
										end if
									end if
								end if								
							end tell
						end if
					end if					
				end repeat			
			end tell
		end repeat
	end tell
	display dialog "Done."
end tell