Author Topic: Importing text files into Quark with quark styles intact  (Read 1839 times)

0 Members and 1 Guest are viewing this topic.

Offline mbornbach

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Importing text files into Quark with quark styles intact
« on: December 28, 2016, 02:33:45 PM »
I'm trying to make our print production manager's life easier and I'm having trouble pulling text files into Quark with styles intact. I would like Quark to import the text and automatically apply the relevant styles.

I tried using rtf files and Microsoft Word styles. If I made a Microsoft Word style named "Headline" with 7 pt. XB Futura ExtraBold text, Quark would import the files with 7 pt. XB Futura ExtraBold text, but Quark would not apply the corresponding Quark style named "Headline"

I found an article that suggested using @tags within plain text files at http://www.tek-tips.com/viewthread.cfm?qid=657109. Unfortunately, when I tried that, it simply imported the words "@Headline:" instead of applying the headline style in Quark. If you have any advice on how to get text files to import into Quark with the relevant quark styles intact, I would appreciate it. (Don't say switch to InDesign, I tried to sell that and not everyone is as enthusiastic about the idea as I am, lol)

(Running Quark 9.5 and Microsoft Office 2011)

------------------------------------------------------------------------

For what it's worth, I have a script that is pulling info into the text files using Excel and Microsoft Word. (posted below in case anyone is curious). Aside from getting the formatting to work the way I want it to, the script works perfectly. Once I figure out how to work with imported text and styles in Quark, I'll add the relevant parts to the script and post the final script in the scripting section.


Code: [Select]
---------------------------------------------------------------------------------------------------
--PROMPTING THE USER TO SELECT THE FOLDER WITH THE EXCEL FILES
---------------------------------------------------------------------------------------------------

with timeout of 900 seconds

--Displaying a prompt asking the user to select the excel file with the information
set excel_folder to choose folder with prompt "Select the folder with the excel files"

tell application "Finder" to set excel_file_list to (every file of folder excel_folder whose name extension contains "xls") as alias list

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------
--OPENING THE WORKBOOK IN EXCEL
---------------------------------------------------------------------------------------------------

--Opening each Excel file
repeat with my_file in excel_file_list

set product_info to POSIX path of my_file
do shell script "open -a /Applications/Microsoft\\ Office\\ 2011/Microsoft\\ Excel.app " & quoted form of product_info
delay 10

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------
--GETTING INFO FROM EACH EXCEL ROW TO PASTE INTO WORD
---------------------------------------------------------------------------------------------------

--Repeating with every used row
set the_start_row to 2
tell application "Microsoft Excel"
tell active sheet
repeat with i from 1 to count of rows of used range
set current_row to i


--Setting the cell address for each info field
set sku_number_cell to "E" & current_row as string
set mfg_number_cell to "F" & current_row as string
set vendor_cell to "G" & current_row as string
set description_cell to "H" & current_row as string
set long_description_cell to "W" & current_row as string
set the_specs_cell to "X" & current_row as string
set the_url_cell to "Y" & current_row as string


--Getting the values from every cell address
if current_row is greater than or equal to the_start_row then
set sku_number to value of cell sku_number_cell as string
set mfg_number to value of cell mfg_number_cell as string
set the_vendor to value of cell vendor_cell as string
set the_description to value of cell description_cell as string
set long_description to value of cell long_description_cell
set the_specs to value of cell the_specs_cell
set the_url to value of cell the_url_cell

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------
--PASTING THE INFO INTO A MICROSOFT WORD DOCUMENT & APPLYING STYLES
---------------------------------------------------------------------------------------------------

--Doctoring the vendor name if it contains "/"
if the_vendor contains "/" then
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set text_items to text items of the_vendor
set AppleScript's text item delimiters to "_"
set the_vendor to text_items as Unicode text
set AppleScript's text item delimiters to astid
end if

--Setting the path in which to save the word document
set desktop_folder to path to desktop as string
set the output_path to desktop_folder & sku_number & "_" & the_vendor & ".rtf"


--Opening Microsoft Word
tell application "Microsoft Word"
activate


--Creating a new Word document
make new document


--Choosing which info to paste into word
set sale_price to "0099 SALE" & return
set description_heading to the_vendor & " " & the_description & return
set the_sku_number to sku_number & return
set regular_price to "Reg. 00.99"
set product_text to sale_price & description_heading & the_sku_number & regular_price


--Inserting/pasting that info into Word
insert text product_text at beginning of text object of active document


--Creating the basic paragraph style
set paragraph_style to make new Word style at active document with properties
{name local:"A Basic Price", style type:style type paragraph}
set line spacing of paragraph format of paragraph_style to "20"
set alignment of paragraph format of paragraph_style to align paragraph center
set space after of paragraph format of paragraph_style to "0.035"
set hyphenation to false


--Creating the Headline Character Style
set headling_style to make new Word style at active document with properties
{name local:"Headline", style type:style type character}
set name of font object of headling_style to "XB Futura ExtraBold"
set font size of font object of headling_style to "7"

--Applying Paragaph Style
set style of text object of paragraph 1 of selection to paragraph_style

--Finding Headline
set findRange to find object of selection
tell findRange
set description_part to execute find find text description_heading
log description_part
end tell


--Applying Headline Character Style
set style of text object of selection to "Headline"

--Saving and closing the document
try
save as active document file name output_path file format format rtf

--Overwriting file if it already exists
on error
try
set output_file to output_path as alias
tell application "Finder"
if exists output_file then
delete file output_file
tell application "Microsoft Word" to save as active document file name output_path file format format rtf
end if
end tell
end try
end try

tell active document to close saving no

end tell

log output_path

end if
end repeat
end tell
end tell
end repeat
end timeout
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------

Offline mbornbach

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Re: Importing text files into Quark with quark styles intact
« Reply #1 on: December 28, 2016, 02:49:34 PM »
It looks like simply saving the files as .docx files instead of .rtf files makes Quark happy. :)