Problems with Excel 2003.

  • Thread starter Thread starter kosecki
  • Start date Start date
K

kosecki

Hi,

I can't find the way to do something from vb .net in current copy of
Excel. All posts which I read tell how to make application.excel object
and do something. I need to write something like addin for eg:

-Excel is activated and some file is loaded
then i'd like lounch my .net program which has some button
when I press the button some text is jot down in
activesheet/activecell.

Please help, how to do this.

Peter.
 
Hi,

here is an example of some code I used in my application to do some input in
an excel worksheet. Comments and values are in Dutch, but this shoudn't be a
problem, I guess...
Private Sub MicrosoftExcelToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MicrosoftExcelToolStripMenuItem.Click

'Declareer de variabelen voor de Excel objecten

Dim exlAppl As Excel.Application

Dim exlWbook As Excel.Workbook

Dim exlWsheet As Excel.Worksheet

'Wijs een waarde toe aan de variabelen

exlAppl = CType(CreateObject("Excel.Application"), Excel.Application)

exlWbook = CType(exlAppl.Workbooks.Add, Excel.Workbook)

exlWsheet = CType(exlWbook.Worksheets(1), Excel.Worksheet)

'Voeg data toe aan het excel werkblad

With exlWsheet

..Columns.ColumnWidth = 11

..Range("A1").Value = "METRISCHE GARENLENGTE OMGEZET NAAR ALLE NUMMERSOORTEN"

With .Range("A1")

..Font.Bold = True

..Font.Size = 12

..Font.Color = 115

End With

..Range("B1").ColumnWidth = 5

..Range("A3").Value = "Metrische lengte ="

..Range("C3").Value = Me.txtMetrLengte.Text

With .Range("E5")

..Value = "GETWIJND"

..Font.Bold = True

..HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter

End With

..Range("C6").Value = "Enkel"

..Range("D6").Value = "2-draad"

..Range("E6").Value = "3-draad"

..Range("F6").Value = "4-draad"

With .Range("C6", "F6")

..Font.Bold = True

..HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter

End With

...........
 
I'know where is the key:

I need to use:

dim myExcekl as Object
myExcel = GetObject(, "Excel.Application")
myActive = myExcel.ActiveSheet
......
 
Back
Top