Good morning, my software works with bar code reading for generating printed labels. It has several Texbox, each one receiving from the reader a different code. When I click on Save it sends these codes to an Excel worksheet where I can print and attach in the box with the products. Only I could do that every time I clicked Save, it overwrites a template, in this case for formatting and name of the company are organized, but when there is a "BO" error, instead of looking for the file in xls referring to those tags, it is necessary to re-beep because the file does not exist, since it will always overwrite the previous one, Click Save, and every time it generates a new file, referencing it with the number of the box that is filled in a texbox?
//Criando arquivo no Excel.exe:
Microsoft.Office.Interop.Excel.Application Excel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook sheet = Excel.Workbooks.Open("C:\Users\Core i3\Desktop\EtiqMasterBoxTornozeleira.xlsx");
Microsoft.Office.Interop.Excel.Worksheet x = Excel.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;
Excel.Range userRanger = x.UsedRange;
int countRecords = userRanger.Rows.Count;
int add = countRecords + 1;