I'm new to VS and C# programming and I would like to create one generic function/method that will return a Boolean value and pass in either the Word or Excel object, what object reference would I need to use in C#? I?d prefer not to create two parameters but one.
Objects to pass in:
Word.Document myDoc= myWordApp.Documents.Open(FileName: FileName, ReadOnly: false);
Excel.Workbook myExcelWorkBook = myExcelApp.Workbooks.Open(Filename: FileName, ReadOnly: false);
I've created the method below:
public void FindExcelMacros(ref Boolean HasMacro, Excel.Workbook myExcelWorkBook)
{ if (myExcelWorkBook.HasVBProject)
{
HasMacro = true;
return;
}
HasMacro = false;
}
But would like something belowublic void CheckForMacros(ref Boolean HasMacro, Excel or Word Object MsOfficeObject)
{
if (MsOfficeObject.HasVBProject)
{
HasMacro = true;
return;
}
HasMacro = false;
}
Thank you,
William
Objects to pass in:
Word.Document myDoc= myWordApp.Documents.Open(FileName: FileName, ReadOnly: false);
Excel.Workbook myExcelWorkBook = myExcelApp.Workbooks.Open(Filename: FileName, ReadOnly: false);
I've created the method below:
public void FindExcelMacros(ref Boolean HasMacro, Excel.Workbook myExcelWorkBook)
{ if (myExcelWorkBook.HasVBProject)
{
HasMacro = true;
return;
}
HasMacro = false;
}
But would like something belowublic void CheckForMacros(ref Boolean HasMacro, Excel or Word Object MsOfficeObject)
{
if (MsOfficeObject.HasVBProject)
{
HasMacro = true;
return;
}
HasMacro = false;
}
Thank you,
William