HRESULT error when inserting a formula

  • Thread starter Thread starter adrian
  • Start date Start date
A

adrian

hello!

i am using visual studio 2000 and am trying to insert a formúla into
an excel cell. the code goes like this:

with excel
.workbooks.open (datei(i))
.activesheet.name ="statistik 2004"
.activesheet.range("b7").select()
.selection.insert()
.range("b7").formular1c1 = "=rc[-1]*1"
end with

excel is defined as excel.application

i have problems with the formular1c1 command. i think the syntax is
ok, but when i am executing the application visual basic shows me a
messagebox with

"An unhandled exeption of type
'system.runtime.interopservices.comexception' occured in mscorlib.dll.
Additional information: Exception from HRESULT: 0x800A03EC"

can anyone help me?

adrian




--------------------------------------------------------------------------------
 
From some old VB6 code I have lying around...

Set xlApp = New Excel.Application
' base workbook on template that contains some predefined macros...
Set xlBook = xlApp.Workbooks.Add(gsNetPath & "\mytemplate.xlt")

Dim xlSheet As Excel.Worksheet
Set xlSheet = xlBook.Worksheets.Add

xlSheet.Range("B7").Value = "=RC[-1]*1"

Looks like I was using Value property when I needed to add a formula...

untested

HTH,
Greg



adrian said:
hello!

i am using visual studio 2000 and am trying to insert a formúla into
an excel cell. the code goes like this:

with excel
.workbooks.open (datei(i))
.activesheet.name ="statistik 2004"
.activesheet.range("b7").select()
.selection.insert()
.range("b7").formular1c1 = "=rc[-1]*1"
end with

excel is defined as excel.application

i have problems with the formular1c1 command. i think the syntax is
ok, but when i am executing the application visual basic shows me a
messagebox with

"An unhandled exeption of type
'system.runtime.interopservices.comexception' occured in mscorlib.dll.
Additional information: Exception from HRESULT: 0x800A03EC"

can anyone help me?

adrian




--------------------------------------------------------------------------
------
 
hello!

since i am still not able to solve the problem here's more code. hope
it will help...

public class form1
inherite system.windows.forms.form
dim excel as excel.application
dim exlsheet as excel.worksheet
dim exlbook as excel.workbook
dim beginn, ende as integer
dim datei(53) as string
dim i as integer

private sub button1_click(...)
datei(1)= "...."
datei(2)= "...."
....

beginn = beginn_eingabe.text
ende = ende_eingabe.text
excel = createobject ("excel.application"
excel.visible = true
i = beginn
do
exlbook = excel.workbooks.open (datei(i))
exlsheet = exlbook.activesheet
with exlsheet
.name = "..."
.columns ("B:B").Insert()
.range ("b7").formular1c1 = "=RC[-1]*1"
.....

the application is interupting at the last command (formular1c1). i
don't know whats the problem. please help me!!!!

thanks in advance

adrian


p.s. i am using microsoft visual studio 2002 and excel xp
 
Back
Top