lundi 7 juin 2021

Can C# be used to create macro-enabled word documents?

Is it possible to create a macro-enabled word file (.docm) using C# and Microsoft.Office.Interop.Word library?

An example of a macro I need would be:

Private Sub CheckBox1_Click()
    If CheckBox1.Value = False Then
        Paragraph1.Value = "aaa"
    End If
End Sub

This macro would not be run by C#, but rather when a user opens the word document and clicks a CheckBox.

Essentially, I'm trying to automatically generate a couple of .docm word templates without having to manage every file individually using the Visual Basic for Applications in Word. Is this possible in C# or there some other library I can use in Visual Basic (using Visual Studio IDE)?

Any replies would be greatly appreciated as I haven't been able to find anything about creating .docm files directly in C#.




Aucun commentaire:

Enregistrer un commentaire