Jump to content

I'm lost stupid help needed again.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
williamevanl

williamevanl

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
I'm loading a workbook from an excel add in with something like...

Excel.Loadworkbook thenameof = this.Application.Runtime, missing, missing,missing etc...

Anyway, my question is in this example what is "thenameof" called, is it a variable, object what?
And more importantly how do I have that name change inside of a loop. I need that line to run 15 times with just thenameof part changing so:

for( i = 1; 1 <=15 i++)
excel.Loadworkook thenameof_i = this.Application.Runtime, missing, missing, missing etc...

How do I append that, I've tried a bunch of things and it always results in errors.

#2
hampus.tagerud

hampus.tagerud

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts
From what I understand, you want to import multiple workbooks, right?

Then I would suggest that you make an array of workbooks. I have never tried to load a workbook, so I can´t promise that it will work and I can´t tell you how to do it. But to change the name of an array in a loop is quite easy:

for(int i = 0; i<15; i++)
thenameof[i] = this.Application.Runtime, missing, missing, missing etc...

Sorry if I didn´t understand you;)

#3
williamevanl

williamevanl

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
The problem I run into is that I can't place "thenameof[i] = this.Application.Runtime, missing, missing, missing etc..."

in front of

Excel.Loadworkbook

without causing an error.

#4
hampus.tagerud

hampus.tagerud

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts
Loading and reading the Microsoft Excel file contents using C# - CodeProject

This article seems to tell you how to load a workbook properly!