Is it possible to convert VBA to C#?

前端 未结 4 1256
予麋鹿
予麋鹿 2020-12-05 11:28

I have a few modules of block of code in VBA to run on few Access databases. I would like to know how I should proceed if I want to convert the coding to C# environment. An

4条回答
  •  悲&欢浪女
    2020-12-05 12:15

    One thing to be aware of is that some object name spaces and library references are included automatically when you are coding in VBA. These need to be explicitly added when working in C#. For example,

    Selection.TypeText("foo")
    

    in VBA becomes

    using Microsoft.Office.Interop.Word;
    
    Application word = new Application();
    word.Selection.TypeText("foo");
    

    in C#. Library references can be added by right-clicking the References folder in the Solution Explorer and choosing "Add Reference".

提交回复
热议问题