Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions Document-Processing/Excel/Excel-Library/NET/Working-with-Macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
IVbaModules vbaModules = project.Modules;

//Opening form module existing workbook
FileStream input = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xls"), FileMode.Open, FileAccess.ReadWrite);
IWorkbook newBook = application.Workbooks.Open(input);
IWorkbook newBook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xls"));

IVbaProject newProject = newBook.VbaProject;

Expand All @@ -470,7 +469,6 @@ using (ExcelEngine excelEngine = new ExcelEngine())
#endregion

//Dispose streams
input.Dispose();
outputStream.Dispose();
}
{% endhighlight %}
Expand Down Expand Up @@ -779,8 +777,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xls"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xls"), ExcelOpenType.Automatic);
IWorksheet sheet = workbook.Worksheets[0];

//Accessing Vba project
Expand All @@ -804,7 +801,6 @@ using (ExcelEngine excelEngine = new ExcelEngine())
#endregion

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
{% endhighlight %}
Expand Down Expand Up @@ -900,8 +896,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xls"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xls"), ExcelOpenType.Automatic);
IWorksheet sheet = workbook.Worksheets[0];

//Accessing Vba project
Expand All @@ -920,7 +915,6 @@ using (ExcelEngine excelEngine = new ExcelEngine())
#endregion

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
{% endhighlight %}
Expand Down Expand Up @@ -988,8 +982,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xls"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xls"), ExcelOpenType.Automatic);
IWorksheet sheet = workbook.Worksheets[0];

//Accessing Vba project
Expand All @@ -1008,7 +1001,6 @@ using (ExcelEngine excelEngine = new ExcelEngine())
#endregion

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
{% endhighlight %}
Expand Down Expand Up @@ -1074,8 +1066,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xls"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xls"), ExcelOpenType.Automatic);
IWorksheet sheet = workbook.Worksheets[0];

//Accessing Vba project
Expand All @@ -1094,7 +1085,6 @@ using (ExcelEngine excelEngine = new ExcelEngine())
#endregion

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
{% endhighlight %}
Expand Down Expand Up @@ -1161,8 +1151,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xls"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xls"), ExcelOpenType.Automatic);
IWorksheet sheet = workbook.Worksheets[0];

//Skip Macros while saving
Expand All @@ -1175,7 +1164,6 @@ using (ExcelEngine excelEngine = new ExcelEngine())
#endregion

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
{% endhighlight %}
Expand Down