Is there any way to read data from an xls file during pre install? I want the installer to behave a certain way depending on what is in the xls file.

asked 25 Sep '12, 12:33

jamminjase's gravatar image

accept rate: 0%

InstallBuilder does not provide built-in actions to perform such actions and we do not recommend performing such complex things as reading XLS files and depending on it in the installer. We recommend using XML or INI files and using <iniFileGet> and<xmlfileget>` actions.

However, if the installer is always run on machines where Microsoft Office is already installed, it is possible to run cscript and access Microsoft Office from Visual Basic.

Below is an InstallBuilder sample that unpacks and runs a .vbs script:

<unpackFile> <component>xlstest</component> <destination>${system_temp_directory}\xlstest.vbs</destination> <folder>xlstest</folder> <origin>xlstest.vbs</origin> </unpackFile> <runProgram> <program>cscript</program> <programArguments>/NOLOGO "${system_temp_directory.dos}/xlstest.vbs"</programArguments> </runProgram> <deleteFile> <path>${system_temp_directory}\xlstest.vbs</path> </deleteFile> <showInfo> <text>Output from cscript: ${program_stdout} </text> </showInfo>

Below is an example Visual Basic code of printing value of A1 cell in Sheet1 of xlsfile.xls file in current directory:

Dim ExcelApp As Excel.Application, XlsBook As Excel.Workbook, XlsSheet As Excel.Worksheet Set ExcelApp = New Excel.Application Set XlsBook = ExcelApp.Workbooks.Open("xlsfile.xls") Set XlsSheet = XlsBook.Worksheets("Sheet1") WScript.Print XlsSheet.Cells(1, 1).Value ExcelApp.Quit


answered 25 Sep '12, 14:02

wojciechka's gravatar image

wojciechka ♦♦
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 25 Sep '12, 12:33

Seen: 514 times

Last updated: 25 Sep '12, 14:02

Related questions