Answer the question
In order to leave comments, you need to log in
How to run a macro from C#?
I have a macro (.docm) that opens an rtf file and saves it as a doc. This macro needs to be run from a C# application. How to do it?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Создание экземпляра Word
Word.Application app = new Word.Application();
app.Visible = true;
Word.Documents doc = app.Documents;
// Открытие файлов
MessageBox.Show("Добавьте файл с макросом");
OpenFileDialog macroFile = new OpenFileDialog();
if (macroFile.ShowDialog() != DialogResult.OK)
{
MessageBox.Show("Ошибка открытия макроса");
return;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question