Excel disp e badindex

************** Текст исключения **************

System.Runtime.InteropServices.COMException (0x8002000B): Неверный индекс. (Исключение из HRESULT: 0x8002000B (DISP_E_BADINDEX))

в Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)

в Microsoft.VisualBasic.CompilerServices.NewLateBind ing.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)

в WindowsApplication1.Form_Main_Window.Form_Main_Win dow_Load(Object sender, EventArgs e)

в System.EventHandler.Invoke(Object sender, EventArgs e)

в System.Windows.Forms.Form.OnLoad(EventArgs e)

в System.Windows.Forms.Form.OnCreateControl()

в System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

в System.Windows.Forms.Control.CreateControl()

в System.Windows.Forms.Control.WmShowWindow(Message& m)

в System.Windows.Forms.Control.WndProc(Message& m)

в System.Windows.Forms.Form.WmShowWindow(Message& m)

в System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Загруженные сборки **************

mscorlib

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2633.0 built by: NET471REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

—————————————-

Бриз_ПП

Версия сборки: 1.7.0.1

Версия Win32: 1.7.0.1

CodeBase: file:///C:/Breez_PP/%D0%91%D1%80%D0%B8%D0%B7_%D0%9F%D0%9F_x64.exe

—————————————-

Microsoft.VisualBasic

Версия сборки: 10.0.0.0

Версия Win32: 14.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll

—————————————-

System

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

—————————————-

System.Core

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2633.0 built by: NET471REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

—————————————-

System.Windows.Forms

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

—————————————-

System.Drawing

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

—————————————-

System.Configuration

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

—————————————-

System.Xml

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2612.0 built by: NET471REL1LAST_B

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

—————————————-

System.Runtime.Remoting

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll

—————————————-

System.Data

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2633.0 built by: NET471REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll

—————————————-

System.Data.resources

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/System.Data.resources.dll

—————————————-

System.Transactions

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll

—————————————-

System.EnterpriseServices

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll

—————————————-

Microsoft.Office.Interop.Excel

Версия сборки: 15.0.0.0

Версия Win32: 15.0.4569.1506

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll

—————————————-

office

Версия сборки: 15.0.0.0

Версия Win32: 15.0.4613.1000

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll

—————————————-

mscorlib.resources

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/mscorlib.resources.dll

—————————————-

System.Windows.Forms.resources

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/System.Windows.Forms.resources.dll

—————————————-

I’m trying to deploy an application that works fine on my development pc and some other workstations.
However, some users receive an error that I can’t seem to grasp.

The program is a C# dotNet app with Excel.Interop functionality (Office 2003).

I seem to be getting a problem with ‘indexes’. The weird thing is that this part works perfect on some machines but throws a fatal exception on others…
All machines are Windows 7 with Office 2003.

This is the relevant code:

//Change sheet code (index is 1, 2, 3) -> errors at #2
public void ChangeWorksheet(int sheetIndex)
{
    if (_OnXLSEvent != null) _OnXLSEvent(string.Format("TEMP: working on page {0}", sheetIndex));
    _WS = _WSs[sheetIndex];
    _Shapes = _WS.Shapes;
    _PageSetup = _WS.PageSetup;
    if (_OnXLSEvent != null) _OnXLSEvent(string.Format("TEMP: working on page {0}", _WS.Name));
}

//Constructor (_App and _WBs are static)
public ExcelProcessor(bool SaveAutomatically = false, string SavePath = "")
{
    if (_App == null)
        _App = new XLS.Application();
    if (_WBs == null)
        _WBs = _App.Workbooks;
    _WB = _WBs.Add();
    _WSs = _WB.Sheets;
    _WS = _WSs[1];
    _Shapes = _WS.Shapes;
    _PageSetup = _WS.PageSetup;
    _SavePath = SavePath;
    _SaveOnDispose = SaveAutomatically;
    _App.DisplayAlerts = false;
    ApplyPageSetup();
}

This is the log that I’m receiving:

... Irrelevant
8:52:   TEMP: working on page 1
8:52:   TEMP: working on page Sheet1
8:52:   TEMP: working on page 2
8:52:   Error occurred:
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
at Microsoft.Office.Interop.Excel.Sheets.get__Default(Object Index)
at Classes.XLSInterop.ExcelProcessor.ChangeWorksheet(Int32 sheetIndex) in     c:UserspanjajDocumentsVS ProjectsProjectsClient   ProjectsProFormaCreatorProFormaCreatorClassesXLSInteropExcelProcessor.cs:line 74
at Classes.ApplicationManager.Manager.ProcessSingleDocument(InFileDocument doc) in c:UserspanjajDocumentsVS ProjectsProjectsClient ProjectsProFormaCreatorProFormaCreatorClassesApplicationManagerApplicationManager.cs:line 327
at Classes.ApplicationManager.Manager.ConvertFile(String File) in c:UserspanjajDocumentsVS ProjectsProjectsClient ProjectsProFormaCreatorProFormaCreatorClassesApplicationManagerApplicationManager.cs:line 172

See more:

I’m trying to create sheet4 with name as «AutoIntegration» but it showing error:» DISP_E_BADINDEX», its working fine upto sheet3, but failing at sheet4

Please help

If dlgSave.ShowDialog = Windows.Forms.DialogResult.OK Then
Try

xlApp = New Microsoft.Office.Interop.Excel.Application
xlBook = xlApp.Workbooks.Add(oValue)

‘############### EXPORT TO SHEET1 ##########################

Dim xlRow As Long = 2
Dim xlCol As Short = 1
xlSheet = xlBook.Worksheets(«Sheet1»)
xlSheet.Name = «General»

For Each col As DataColumn In dtgl.Columns
xlSheet.Cells(1, xlCol) = col.ColumnName
xlCol += 1
Next
For Each row As DataRow In dtgl.Rows
xlCol = 1
For Each col As DataColumn In dtgl.Columns
xlSheet.Cells(xlRow, xlCol) = row(xlCol — 1)
xlCol += 1
Next
xlRow += 1
Next
‘############### EXPORT TO SHEET2 ##########################
Dim xlRow2 As Long = 2
Dim xlCol2 As Short = 1
xlSheet = xlBook.Worksheets(«Sheet2»)
xlSheet.Name = «Transport»

For Each col As DataColumn In dttt.Columns
xlSheet.Cells(1, xlCol2) = col.ColumnName
xlCol2 += 1
Next

For Each row As DataRow In dttt.Rows
xlCol2 = 1
For Each col As DataColumn In dttt.Columns
xlSheet.Cells(xlRow2, xlCol2) = row(xlCol2 — 1)
xlCol2 += 1
Next
xlRow2 += 1
Next

‘############### EXPORT TO SHEET3 ##########################
Dim xlRow3 As Long = 2
Dim xlCol3 As Short = 1
xlSheet = xlBook.Worksheets(«Sheet3»)
xlSheet.Name = «Radio»

For Each col As DataColumn In dtr.Columns
xlSheet.Cells(1, xlCol3) = col.ColumnName
xlCol3 += 1
Next

For Each row As DataRow In dtr.Rows
xlCol3 = 1
For Each col As DataColumn In dtr.Columns
xlSheet.Cells(xlRow3, xlCol3) = row(xlCol3 — 1)
xlCol3 += 1
Next
xlRow3 += 1
Next

‘############### EXPORT TO SHEET4 ##########################

Dim xlRow4 As Long = 2
Dim xlCol4 As Short = 1
xlSheet = xlBook.Worksheets(«Sheet4»)
xlSheet.Name = «AutoIntegrate»

For Each col As DataColumn In dtau.Columns
xlSheet.Cells(1, xlCol4) = col.ColumnName
xlCol4 += 1
Next

For Each row As DataRow In dtau.Rows
xlCol4 = 1
For Each col As DataColumn In dtau.Columns
xlSheet.Cells(xlRow4, xlCol4) = row(xlCol4 — 1)
xlCol4 += 1
Next
xlRow4 += 1
Next

Question

User clicks ‘Company — Data Entry — Reported Values’. User chooses parameters and clicks ‘Open’. An error appears:

Standard Error:
Source: Microsoft.Office.Interop.Excel
Description: Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)…..

Cause

There are several possible causes for this error:

Scenario #1 (most likely) — Defect (reference APAR PI49912) in early versions of Controller 10.2.1 (10.2.5110.95 and earlier).

  • This is triggered when the client device has an incompatible Excel add-in(s) installed (alongside the Cognos Controller Excel add-in).

Scenario #2 — Microsoft Excel (on the client device) has not been activated.

Answer

Scenario #1
Upgrade to Controller 10.2.1 Fix Pack 2 (10.2.5120.72) or later.

  • See separate IBM Technote #1963875.

Scenario #2
Activate the license of Microsoft Excel (on the client device).

  • See separate IBM Technote #1967095 for full details.

Related Information

[{«Product»:{«code»:»SS9S6B»,»label»:»IBM Cognos Controller»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Component»:»Controller»,»Platform»:[{«code»:»PF033″,»label»:»Windows»}],»Version»:»10.2.1″,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}},{«Product»:{«code»:»SS9S6B»,»label»:»IBM Cognos Controller»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Component»:» «,»Platform»:[{«code»:»»,»label»:»»}],»Version»:»»,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}}]

SOLVED — Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX) in C#

An unhandled exception of type ‘System.Runtime.InteropServices.COMException‘ occurred in XXX.exe.


I received this exception while coding and here are the steps to correct it. This code tries to add a sheet to the Excel workbook.




Error Details:


System.Runtime.InteropServices.COMException was unhandled
HResult=-2147352565
Message=Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
ErrorCode=-2147352565


Step 1: Open MS Excel on your local computer where the above code is running.

Setp 2: Go to File -> Options -> General tab

Step 3: Increase «Include this many sheets» value

Solution 1

Maybe your version of Excel doesn’t speak English. And «sheet» is a dirty word in the local language, it kinda is in English ;) Your name is a hint that English is not the default language. Use the index instead of the name to avoid accidents like this:

    xlWorkSheet = CType(xlWorkBook.Sheets(1), Excel.Worksheet)

Solution 2

This could also be happening because

Workbook.Worksheets.Count

is less than the number of sheets you use, depending on how your Excel settings are. For me it starts with 3 sheets but for a colleague it starts
with 2 sheets.

So you can call

Workbook.Worksheets.Add()

to reach the desired number of sheets

Comments

  • I’m trying to create an Excel file from VB.net from my first time.
    I already added the Microsoft.Office.Excel reference, Import the Microsoft.Office.Interop

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet
        Dim misValue As Object = System.Reflection.Missing.Value
    
        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Excel.Worksheet)
        xlWorkSheet.Cells(1, 1) = "Something here"
        xlWorkSheet.SaveAs("D:vbexcel.xlsx")
    
        xlWorkBook.Close()
        xlApp.Quit()
        releaseObject(xlApp)
        releaseObject(xlWorkBook)
        releaseObject(xlWorkSheet)
    
        MsgBox("Excel file created , you can find the file c:")
    
    End Sub
    

    The error generetad is in the line :

       xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Excel.Worksheet)
    
       Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
    

  • hhhhhhhhhhhhhhhhhhh IT Works

Recents

  

JaZDik

10.01.14 — 08:57

{Форма.Форма.Форма(26)}: Ошибка при вызове метода контекста (Worksheets)

    Док = ТабЕксель.Worksheets(«на.уд.киль»);

по причине:

Произошла исключительная ситуация (0x8002000b)

  

Wobland

1 — 10.01.14 — 08:58

спасибо, не знал

  

Рэйв

2 — 10.01.14 — 09:00

(0)Цифру попробуй, а не текст.

  

JaZDik

3 — 10.01.14 — 09:00

В чем может быть проблема

  

JaZDik

4 — 10.01.14 — 09:01

(2) попробывать например Док = ТабЕксель.Worksheets(«1»); ?

  

Мыш

5 — 10.01.14 — 09:04

Док = ТабЕксель.Worksheets(1);

  

JaZDik

6 — 10.01.14 — 09:07

(5) (2) теперь

{Форма.Форма.Форма(74)}: Значение не является значением объектного типа (Товары)

НоваяСтрока=НовДок.Товары.Добавить();

  

Wobland

7 — 10.01.14 — 09:08

(6) думаешь, оно таки объектного?

  

Мыш

8 — 10.01.14 — 09:08

(6) Что сделать то хочешь?

  

Рэйв

9 — 10.01.14 — 09:08

(6)Посмотри ТипЗнч(НовДок) в табло. Скорее всего удивишься

  

Мыш

10 — 10.01.14 — 09:10

  

JaZDik

11 — 10.01.14 — 09:11

(8) Выгрузить 1с Excel в 1с

  

Мыш

12 — 10.01.14 — 09:12

(11) Может быть прочитать данные из Экселя и записать их в 1С? Я угадал? )

  

JaZDik

13 — 10.01.14 — 09:12

(9) Где это поглядеть. Просто первй раз с этим столкнулся.

  

Мыш

14 — 10.01.14 — 09:13

(13) Ctrl+Alt+W

  

Wobland

15 — 10.01.14 — 09:14

(9) (14) научите его ещё Сообщать вместо шифт+ф9, ага

  

Мыш

16 — 10.01.14 — 09:17

(15) Да ладно. От задачи зависит же. Когда табло удобнее, когда расчет выражения.

  

JaZDik

17 — 10.01.14 — 09:19

(14) Пусто=)

  

Wobland

18 — 10.01.14 — 09:20

(17) внезапно, правда?

  

НаборДанных

19 — 10.01.14 — 09:20

  

Рэйв

20 — 10.01.14 — 09:21

(17)Ну тогда у тебя нарисовалась задача минимум — сделать чтобы оно было типа «ДокументОбъект»:-)

  

НаборДанных

21 — 10.01.14 — 09:22

+Код своей загрузки вывали сюда, подскажут быстрее в 146 раз.

  

Рэйв

22 — 10.01.14 — 09:23

*задумчиво

пора что-то придумывать спрашивать вместо фотки у мужиков. А то нарушаем гармонию Вселенной.

  

JaZDik

23 — 10.01.14 — 09:23

(21) Минуту Щас выгружу… Просто в чем дело то. В старой базе обработка работала. Теперь, когда начали год создали новую бази и там обработка не пашет.

  

Wobland

24 — 10.01.14 — 09:26

(20) стишок или песенку?

  

Wobland

25 — 10.01.14 — 09:27

(24) -> (22)

  

НаборДанных

26 — 10.01.14 — 09:28

(22)Спрашивать у мужиков надо фотки жен или подруг)

  

JaZDik

27 — 10.01.14 — 09:29

  

JaZDik

28 — 10.01.14 — 09:29

Вот обработка

  

Рэйв

29 — 10.01.14 — 09:32

(24)Ага. Видео топикстартера декламирующего стишок, стоя на табуретке:-) Это идея!

  

Рэйв

30 — 10.01.14 — 09:33

(26)Начнут ныть что они бедные , несчастные и насквозь холостые и неоподруженые:-)

  

НаборДанных

31 — 10.01.14 — 09:33

Если  Док.Cells(Row, 1).Value= «К /с 30101810500000000609 пгт. Кильмезь, ул. Свободы, 12 а»  Тогда

Тут у тебя скорее всего условие не пролазит, а далее у тебя уже нет создания дока, думай дальше.

  

НаборДанных

32 — 10.01.14 — 09:34

И, с трудом верится, что это «работало, работало и перестало с нового года!».

  

JaZDik

33 — 10.01.14 — 09:41

(32) В старой базе работало. Она там камазом переханная и не обновленная. Щас стоит БПпроф послденяя… и на ней не пашет

  

Wobland

34 — 10.01.14 — 10:10

(33) а новую базу ты камазом, конечно, переехать забыл

  

andr_andrey

35 — 10.01.14 — 11:02

(32) Думаю, он закрыл всплывшее окно Excel-я. :)

  

Black Friday

36 — 10.01.14 — 11:21

(31) сравнивать значение определенной ячейки с константой? готично…

(33) а если изменятся реквизиты поставщика/покупателя — другую обработку писать?

  

stix2010

37 — 10.01.14 — 15:01

(0) Сейчас писать загрузки через COM немодно, используйте ADO

или загрузку файлов xlsx,

недавно пришлось переписывать загрузки из-за лицензий ms office

I have the following code to open a workbook and keep just one sheet:

//Get a new workbook.
oWB = app.Workbooks.Add(Missing.Value);

int len = oWB.Sheets.Count;

for (int i = 1; i < len; i++)
{
    ((Worksheet)oWB.Sheets[i]).Delete();
}

oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oWB.ActiveSheet;

This code has worked for many years in many client configurations.

For some reason, I have a customer with excel 2013 (in Hebrew), and on his machine I get the following exception:

System.Runtime.InteropServices.COMException (0x8002000B): Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
   at Microsoft.Office.Interop.Excel.Sheets.get__Default(Object Index)
   at IOSIGHT.Win.ActiveReports.ExcelHelper.StartExcel()

If I understand the situation, it seems that for some reason the workbook was left with no sheets,
so then call to oWb.ActiveSheet throws an exception.
Any idea what caused this?

And yes I saw other posts on the same exception, but my code does not match their scenarios.

************** Текст исключения **************

System.Runtime.InteropServices.COMException (0x8002000B): Неверный индекс. (Исключение из HRESULT: 0x8002000B (DISP_E_BADINDEX))

в Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)

в Microsoft.VisualBasic.CompilerServices.NewLateBind ing.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)

в WindowsApplication1.Form_Main_Window.Form_Main_Win dow_Load(Object sender, EventArgs e)

в System.EventHandler.Invoke(Object sender, EventArgs e)

в System.Windows.Forms.Form.OnLoad(EventArgs e)

в System.Windows.Forms.Form.OnCreateControl()

в System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

в System.Windows.Forms.Control.CreateControl()

в System.Windows.Forms.Control.WmShowWindow(Message& m)

в System.Windows.Forms.Control.WndProc(Message& m)

в System.Windows.Forms.Form.WmShowWindow(Message& m)

в System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Загруженные сборки **************

mscorlib

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2633.0 built by: NET471REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

—————————————-

Бриз_ПП

Версия сборки: 1.7.0.1

Версия Win32: 1.7.0.1

CodeBase: file:///C:/Breez_PP/%D0%91%D1%80%D0%B8%D0%B7_%D0%9F%D0%9F_x64.exe

—————————————-

Microsoft.VisualBasic

Версия сборки: 10.0.0.0

Версия Win32: 14.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll

—————————————-

System

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

—————————————-

System.Core

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2633.0 built by: NET471REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

—————————————-

System.Windows.Forms

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

—————————————-

System.Drawing

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

—————————————-

System.Configuration

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

—————————————-

System.Xml

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2612.0 built by: NET471REL1LAST_B

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

—————————————-

System.Runtime.Remoting

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll

—————————————-

System.Data

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2633.0 built by: NET471REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll

—————————————-

System.Data.resources

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/System.Data.resources.dll

—————————————-

System.Transactions

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll

—————————————-

System.EnterpriseServices

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll

—————————————-

Microsoft.Office.Interop.Excel

Версия сборки: 15.0.0.0

Версия Win32: 15.0.4569.1506

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll

—————————————-

office

Версия сборки: 15.0.0.0

Версия Win32: 15.0.4613.1000

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll

—————————————-

mscorlib.resources

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/mscorlib.resources.dll

—————————————-

System.Windows.Forms.resources

Версия сборки: 4.0.0.0

Версия Win32: 4.7.2556.0 built by: NET471REL1

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/System.Windows.Forms.resources.dll

—————————————-

  • Remove From My Forums
  • Question

  • Hello All,

    I’ve recently come across a problem with creating excel files on a particular computer. The computer in question is XP SP3 with Excel 2007. Whenever I try to create an Excel file, add sheets and change the sheet names I come across this error:

    Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

    What confuses me is that the same piece of code in an earlier version of the program worked perfectly fine on the computer. Not only that, but the current code that throws this error on the aforementioned system works perfectly on a machine with XP SP3 and
    Excel 2003, and another with Windows 7 and Excel 2010.

            Dim objExcel As New Excel.Application

            objExcel.Workbooks.Add()
            objExcel.Worksheets.Add()

    Code works fine up until here:

        objExcel.ActiveWorkbook.Worksheets(1).Name = «blah blah»

    My gut is telling me this is more an issue with the system than it is with the code as I’ve tried this before and on different machines and had it working perfectly. I’ve looked at the other 0x8002000B error posts and they weren’t entirely applicable to
    my specific issue.  I’m completely lost though, and would appreciate any comments or advice anyone has on this.

Answers

  • The error does not necessarily come from the index of the worksheet. It can also mean that, inernally, a value <> 0 has been passed to IDispatch::GetTypeInfo.

    Based on the line of your first post,

       objExcel.ActiveWorkbook.Worksheets(1).Name = «blah blah»

    try splitting it:  (Also add the right types with each declaration or As Object if you have option strict off.)

      Dim wb = objExcel.ActiveWorkbook
      Dim sheets = wb.Worksheets
      Dim count = sheets.count ‘if it exists
      Msgbox (count)
      Dim sheet = sheets(0)

    Does the last line throw the exception?


    Armin

    • Marked as answer by

      Wednesday, July 11, 2012 7:02 PM

Я слишком скоро говорил!
Это просто глупая ошибка. Я думал, что дам решение, чтобы другие могли не попасть в ту же ловушку, что и я, -)

Чтобы проанализировать проблему дальше, я добавил следующий код в конструктор:

List<XLS.Worksheet> sheets = new List<XLS.Worksheet>()
foreach(XLS.Worksheet sh in _WSs)
{
    sheets.Add(sh);
}
if(_OnXLSEvent != null) _OnXLSEvent(String.Format("ntSheets in WB: {0}ntFirst Sheet index: {1}, ntLast Sheet index: {2}",
                                                  _WSs.Count,
                                                  sheets[0].Index,
                                                  sheets.Last().Index));

В результате появился следующий журнал на моей машине:

Sheets in WB: 3
First Sheet index: 1, 
Last Sheet index: 3

Но в следующем журнале на целевой машине:

Sheets in WB: 1
First Sheet index: 1, 
Last Sheet index: 1

Заключение: количество рабочих листов, которые стандартно добавлены в новую книгу, отличается от пользователя к пользователю.
Что-то нужно иметь в виду!

  • Remove From My Forums
  • Question

  • Hello All,

    I’ve recently come across a problem with creating excel files on a particular computer. The computer in question is XP SP3 with Excel 2007. Whenever I try to create an Excel file, add sheets and change the sheet names I come across this error:

    Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

    What confuses me is that the same piece of code in an earlier version of the program worked perfectly fine on the computer. Not only that, but the current code that throws this error on the aforementioned system works perfectly on a machine with XP SP3 and
    Excel 2003, and another with Windows 7 and Excel 2010.

            Dim objExcel As New Excel.Application

            objExcel.Workbooks.Add()
            objExcel.Worksheets.Add()

    Code works fine up until here:

        objExcel.ActiveWorkbook.Worksheets(1).Name = «blah blah»

    My gut is telling me this is more an issue with the system than it is with the code as I’ve tried this before and on different machines and had it working perfectly. I’ve looked at the other 0x8002000B error posts and they weren’t entirely applicable to
    my specific issue.  I’m completely lost though, and would appreciate any comments or advice anyone has on this.

Answers

  • The error does not necessarily come from the index of the worksheet. It can also mean that, inernally, a value <> 0 has been passed to IDispatch::GetTypeInfo.

    Based on the line of your first post,

       objExcel.ActiveWorkbook.Worksheets(1).Name = «blah blah»

    try splitting it:  (Also add the right types with each declaration or As Object if you have option strict off.)

      Dim wb = objExcel.ActiveWorkbook
      Dim sheets = wb.Worksheets
      Dim count = sheets.count ‘if it exists
      Msgbox (count)
      Dim sheet = sheets(0)

    Does the last line throw the exception?


    Armin

    • Marked as answer by

      Wednesday, July 11, 2012 7:02 PM

Понравилась статья? Поделить с друзьями:
  • Excel empty if zero
  • Excel discounted cash flow
  • Excel embedding что это
  • Excel disable add on
  • Excel element in list