Is there a way to import a style sheet from my Style Library and have it replace the existing styles? I have tried the following but it didn't work.
Code: Select all
$doc = Document.active
$doc.addStyles 'Manuscript Draft', 'replace'
Lou
Code: Select all
$doc = Document.active
$doc.addStyles 'Manuscript Draft', 'replace'
Code: Select all
$doc = Document.active
$styleDoc = Document.withDisplayName 'Manuscript Draft.rtf'
$doc.addStyles $styleDoc.text, 'replace'
Code: Select all
$doc = Document.active
$dm = DocumentManager.instance
$styleLib = $dm.groupWithName 'Style Library'
$styleLibFiles = $styleLib.allFilePaths
$styleLibFileNames = $styleLibFiles.arrayByMakingValuesDoCommand 'lastFilePathComponentWithoutExtension'
$styleFile = Prompt Options "Choose a stylesheet.", '', 'Choose', $styleLibFileNames
$ind = $styleLibFileNames.indexOfValue $styleFile
if $ind == -1
die "There is no file called $styleFile in your style libarary."
end
$stylePath = $styleLibFiles[$ind]
File.requireAccessAtPath $stylePath
$styleSheet = Document.open $stylePath, false
$doc.addStyles $styleSheet.text, 'replace'
$styleSheet.close
Code: Select all
$doc.addStyles $styleDoc.text
Code: Select all
$doc.addStyles $styleDoc.allStyles