How to set Excel Import Preferences in InDesign CS6 using extendscript?

怎甘沉沦 提交于 2019-12-25 03:38:33

问题


This seems like it should be really simple, but for some reason I can't get it to work at all. The following code has no effect whatsoever:

function setExcelImportPrefs() {  
  with(app.excelImportPreferences){
    rangeName = "A1:Z300";
    sheetName = "whatever";
    tableFormatting = TableFormattingOptions.excelFormattedTable;
  }
}

And this doesn't work either:

function setExcelImportPrefs() {  
  with(app.excelImportPreferences){
    app.excelImportPreferences.rangeName = "A1:Z300";
    app.excelImportPreferences.sheetName = "whatever";
    app.excelImportPreferences.tableFormatting = TableFormattingOptions.excelFormattedTable;
  }
}

What am I doing wrong? I've Googled everything, and I'm at my wits end. (Note: I have InDesign CS6, version 8.0)

Edit: Put in a bracket that I accidentally left out when I was copying-and-pasting.


回答1:


I'm not familiar with these settings, but you seem to have be missing a bracket. Just get rid of the with syntax all together and try

function setExcelImportPrefs() {    
  app.excelImportPreferences.rangeName = "A1:Z300";
  app.excelImportPreferences.sheetName = "whatever";
  app.excelImportPreferences.tableFormatting = TableFormattingOptions.excelFormattedTable;
}


来源:https://stackoverflow.com/questions/24946883/how-to-set-excel-import-preferences-in-indesign-cs6-using-extendscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!