我创建了一个宏来从我的 excel 文件中的空行中删除所有边框。这是米格代码:
Sub RemoveRows()
'
' RemoveRows Macro
'
'
Range("A8").Select
Dim checkval
Dim RowAmount
RowAmount = 93
Do
checkval = ActiveCell.Value
If (checkval = "" Or checkval = Null) Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
RowAmount = RowAmount - 1
Loop While RowAmount > 0
End Sub
运行宏的方法:
public void RemoveRows_Macro(string fileName)
{
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
xlWorkBook = xlApp.Workbooks.Open(fileName);
xlApp.DisplayAlerts = true;
//Run the macro
xlApp.Run("RemoveRows", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
xlWorkBook.Save();
xlWorkBook.Close(false);
xlApp.Quit();
releaseObject(xlApp);
releaseObject(xlWorkBook);
}
我的问题是我可以从我的 C# 应用程序运行此宏而不会出现此错误,但是当其他人使用我的 C# 应用程序时,他们会收到此错误:运行时错误“13”:类型不匹配
我究竟做错了什么 ?