0

I have an excel file that contains some methods written in VB I think. I want to know any way makes me use these methods in C# code. I tried to make a connection with the file using (System.Data.Odbc.OdbcConnection), and then use the UPDATE statement by using Command, but error toke place. So does any one know how to do this?

I uploaded the file on : Download The Excel File

I want to change C20 and C21, then get the data from C22:C29 thanks

1 Answer 1

2

What you are looking at is likely not VB.NET, but VBA (Visual Basic for Applications). VBA is an ancestor of VB.NET, and the language that is used for Excel macros. The bad news for you is, VBA isn't a .NET language, and you can't use C# for macros "attached" to a workbook.

If you are really motivated to use C#, your best option is to look into ExcelDNA, which among other things allows you to call .NET dlls from Excel.

However, I would really question the need to convert to C#, given the problem you describe. VBA is the "natural" language for lightweight Excel automation, and is fairly understandable. If you have existing code, just modify it. And one of the nice features of Excel VBA is the macro recorder, which allows you to record your interactions with Excel as VBA code, which is a great way to figure out how things are used in the object model.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.