Adobe 65009333 Scripting Guide - Page 30

Exporting text and setting text-export preferences

Page 30 highlights

Text and Type Exporting text and setting text-export preferences 30 The following script shows how to set Excel import preferences (for the complete script, see ExcelImportPreferences): //Sets the Excel import filter preferences. with(app.excelImportPreferences){ //alignmentStyle property can be: //AlignmentStyleOptions.centerAlign //AlignmentStyleOptions.leftAlign //AlignmentStyleOptions.rightAlign //AlignmentStyleOptions.spreadsheet alignmentStyle = AlignmentStyleOptions.spreadsheet; decimalPlaces = 4; preserveGraphics = false; //Enter the range you want to import as "start cell:end cell". rangeName = "A1:B16"; sheetIndex = 1; //You'll have to enter a valid worksheet name. sheetName = "pathpoints"; showHiddenCells = false; //tableFormatting property can be: //TableFormattingOptions.excelFormattedTable //TableFormattingOptions.excelUnformattedTabbedText //TableFormattingOptions.excelUnformattedTable tableFormatting = TableFormattingOptions.excelFormattedTable; useTypographersQuotes = true; viewName = ""; } Exporting text and setting text-export preferences The following script shows how to export text from an InCopy document. You must use text or story objects to export in text-file formats; you cannot export all the text in a document in one operation. (For the complete script, see ExportTextFile.) //Creates a story in an example document and then exports the text to a text file. var myDocument = app.documents.add(); var myStory = myDocument.stories.item(0); //Fill the story with placeholder text. var myTextFrame = myStory.textContainers[0]; myTextFrame.contents = TextFrameContents.placeholderText; //Text exportFile method parameters: //Format as ExportFormat //To As File //[ShowingOptions As Boolean = False] // //Format parameter can be: //ExportFormat.inCopyCSDocument //ExportFormat.inCopyDocument //ExportFormat.rtf //ExportFormat.taggedText //ExportFormat.textType // //Export the story as text. You'll have to fill in a valid file path on your system. myStory.exportFile(ExportFormat.textType, File("/c/test.txt"));

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

Text and Type
Exporting text and setting text-export preferences
30
The following script shows how to set Excel import preferences (for the complete script, see
ExcelImportPreferences):
//Sets the Excel import filter preferences.
with(app.excelImportPreferences){
//alignmentStyle property can be:
//AlignmentStyleOptions.centerAlign
//AlignmentStyleOptions.leftAlign
//AlignmentStyleOptions.rightAlign
//AlignmentStyleOptions.spreadsheet
alignmentStyle = AlignmentStyleOptions.spreadsheet;
decimalPlaces = 4;
preserveGraphics = false;
//Enter the range you want to import as "start cell:end cell".
rangeName = "A1:B16";
sheetIndex = 1;
//You'll have to enter a valid worksheet name.
sheetName = "pathpoints";
showHiddenCells = false;
//tableFormatting property can be:
//TableFormattingOptions.excelFormattedTable
//TableFormattingOptions.excelUnformattedTabbedText
//TableFormattingOptions.excelUnformattedTable
tableFormatting = TableFormattingOptions.excelFormattedTable;
useTypographersQuotes = true;
viewName = "";
}
Exporting text and setting text-export preferences
The following script shows how to export text from an InCopy document. You must use text or story
objects to export in text-file formats; you cannot export all the text in a document in one operation. (For
the complete script, see ExportTextFile.)
//Creates a story in an example document and then exports the text to a text file.
var myDocument = app.documents.add();
var myStory = myDocument.stories.item(0);
//Fill the story with placeholder text.
var myTextFrame = myStory.textContainers[0];
myTextFrame.contents = TextFrameContents.placeholderText;
//Text exportFile method parameters:
//Format as ExportFormat
//To As File
//[ShowingOptions As Boolean = False]
//
//Format parameter can be:
//ExportFormat.inCopyCSDocument
//ExportFormat.inCopyDocument
//ExportFormat.rtf
//ExportFormat.taggedText
//ExportFormat.textType
//
//Export the story as text. You'll have to fill in a valid file path on your system.
myStory.exportFile(ExportFormat.textType, File("/c/test.txt"));