Visual Basic will not let me write to an Excel sheet

tonofsteel

Active member
Joined
Jul 10, 2003
Messages
35
I use this code in a public function in the main form, as it needs to be used in several completely different occations. It works perfect if i but it in a button, but as soon as it is inside a function I call..... trajedy:
Code:
                If WriteString <> Nothing Then
                    xlSheet.Cells(yer, counter - (10 - i)) = WriteString
                End If

And I get this error:

An unhandled exception of type System.Runtime.InteropServices.COMException occurred in mscorlib.dll

Additional information: Exception from HRESULT: 0x800A03EC.
 
Are you making sure that the file you are trying to write to is not open already, and that it is not read-only? I believe that particular error means "Could not open the file for writing" or something like that. I didnt get many results on Google, but thats what I could gather.
 
Ah yes, that was the problem. I just made another instance of excel (instead of another sheet in the current book, or another book) and put the new info into there. Works perfect now.

Thank you
 
Back
Top