Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005

    Unanswered: Opening Workbooks Programatically

    I'm using VB.Net to manipulate a few Excel workbooks. Recently I ran across a computer (a customer's) that will only allow me to open one workbook. An attempt to open the second workbook causes an abort. Again, this program works on many other computers but not on this one. It seems like the problem is related to either a security setting or something within Excel that is preventing the opening of the second workbook.

    The second workbook is simply a CSV file that I copy the data and paste it into another file. Below is the code that has worked for years and still works on all but machines but the one in question.

    'If CSV file exists
    If File.Exists(uvlFile) Then
    'Open CSV file into a new workbook in the open Excel.
    oExcel.Workbooks.OpenText(Filename:=uvlFile, _
    Origin:=Excel.XlPlatform.xlMSDOS, _
    DataType:=Excel.XlTextParsingType.xlDelimited, _
    I even modified this to the following but still get the same problem.

    oExcel.Workbooks.Open(Filename:=uvlFile, _
    Origin:=Excel.XlPlatform.xlMSDOS, _
    The open command seems to work and I get the abort when trying to access the "opened" workbook. This is Workbook(2) below. I get an error related to an invalid index. This is a valid error because the second workbook never opens.

    ' Acquire Template "Data" and CSV input worksheets
    oShtTPL = CType(oExcel.Workbooks(1).Worksheets("Data"), Excel.Worksheet)
    oShtCSV = CType(oExcel.Workbooks(2).Worksheets(1), Excel.Worksheet)
    Is onyone aware of an Excel setting that would prevent opening multiple workbooks from one application?

  2. #2
    Join Date
    Jun 2012
    Greyton, South Africa
    I don't see why it wouldn't open. Can you confirm that you can open the workbook manually? Can you open it from say VBA in another workbook in Excel?

    Although you can retrieve the data from the CSV without opening it. ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts