vb.net - Calling Sheet from a WorkBook -
I am trying to call 5th Sheet in an open workbook. But calling the sheet is open if the file is already open but all my efforts Q: Or I have seen many examples, but I do not understand where I am getting wrong Which is surprising because there are so many questions about this topic. Thank you! It's my surprise, I found out that there are dozens of examples of actually running Excel in the background. When I'm debugging and launching COM, the first example of Excel has started. The second starts when I open the windows form (the main part of the add-in). What I did not know was that when an exception was thrown, and I stopped things from within the visual studio, only the first instance of Excel was closed. I have a code that tries to clear and clear Excel's applications but it certainly can not be reached because the exception was thrown. And here I was thinking that I will make an error in handling the error in the short time on the road. I have some more developed things. I obviously need to deal with some basic error which is my build process Are very long ago. I am completely taught, and by no means has it been three years without becoming an issue. Hopefully someone else was not taught who could see it before pulling his hair for 14 hours. Solution Close all other instances of Excel and the code above works to deal with the error and clean the addresses previously addressed here: maybe call GC, although this Is controversial. Last Code:
Personal sub button 1_Click (as the S-Ender object, in the form of e EventArgs) Handle Button1.Click Due CurrentRun Microsoft.Office.Interop.Excel.Application Default CurrentBook Excel.Workbook Slow CurrentSheet As Excel.Worksheet CurrentRun = System.Runtime.InteropServices.Marshal.GetActiveObject ("Excel. Eidan ") CurrentBook = CurrentRun.ActiveWorkbook CurrentSheet = CurrentBook.Sheets (4) CurrentSheet.Activate () End Sub
.... Import Systems Runtime. Interop Services .... New Exxl as Dim PresentRine Excel as Epilink Dim presentbook Workbook Deem Excel as Current Sheet Worksheets .... Private All Buttons 1_Click (Sender as Object, and Event as ARG) Button 1 Handles. Error Click Go to Goto VortexInYourSoul CurrentRun = System.Runtime.InteropServices.Marshal.GetActiveObject ( "Excel.Application") Wartmanbuk = CurrentRun.Workbooks (1) CurrentRun.Visible = True CurrentSheet = CurrentBook.Sheets (8) CurrentSheet.Activate ( ) CurrentBook.ActiveSheet.name = "Exit from Lama Lala Lammalik" .... Sub VortexInYourSoul: CurrentSheet = Nothing CurrentBook.Close (false) CurrentBook = None CurrentRun.Quit () CurrentRun = None MsgBox ("Error : "And Err.Description) End Sub
Comments
Post a Comment