2024.04.06 03:34 Kalorifik Download Tableau extract via Power Query?
2015.09.10 17:59 SmokesInTheNight C# issues with Excel?
using Microsoft.Office.Interop; using Excel = Microsoft.Office.Interop.Excel; //other usings.... namespace MyExcelProgram { class Program { static void Main(string[] args) { Excel.Application myExcelApp; Excel.Workbooks myWorkbooks; Excel.Workbook myWorkbook; Excel.Worksheet myWorksheet; myExcelApp = new Excel.Application(); myExcelApp.Visible = true; myExcelApp.EnableEvents = true; myWorkbooks = myExcelApp.Workbooks; myWorkbook = myWorkbooks.Open(strWorkbookName); myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets["Sheet1"]; //sometimes this throws an exception strData = (myWorksheet.Cells[7, 12] as Excel.Range).Value.ToString(); //sometimes this throws an exception myExcelApp.Run("MacroThatUsesAddin"); //sometimes this throws an exception myWorkbook.Save(); //sometimes this throws an exception myWorkbook.Close(false); //sometimes this or any of the below throws an exception myWorkbooks.Close(); myExcelApp.Quit(); Marshal.ReleaseComObject(myWorksheet); Marshal.ReleaseComObject(myWorkbook); Marshal.ReleaseComObject(myWorkbooks); Marshal.ReleaseComObject(myExcelApp); myWorksheet = null; myWorkbook = null; myWorkbooks = null; myExcelApp = null; } } }Again, what really drives me crazy is that the SAME code randomly throws an exception, sometimes it's fine, sometimes no. Any ideas or suggestions would be appreciated.
2014.02.07 20:53 anonymousking1 VBA Script Error 1004
Sub RenameWorksheets() For Each myWorksheet In Worksheets myWorksheet.Name = myWorksheet.Range("B1").Value Next End SubWhat the above code is supposed to do is that copy the value of the B1 cell and change the name of the sheet to that value. I have three sheets in the workbook and all of them have something written in the B1 cell. When I run the macro I am getting this error despite writing the EXACT same code as the example.