I have an issue that is perplexing me now. Backstory: I have a windows form add in program for excel that opens from inside Excel. I need to refer to the Active Workbook to get the variables (like fullname) to populate correctly. I have this set up:
If I refer to the workbook explicitly, like so:
it works as expected. If I refer to it as the active workbook (as it will need to work dynamically with whatever workbook its open in) the variable comes back as "Nothing".
Is there a way to make the variable "xlWorkbook" dynamically refer to whatever workbook is open?
VB.NET:
Imports Excel = Microsoft.Office.Interop.Excel
<..omitted for brevity...>
Dim xlApp = New Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
If I refer to the workbook explicitly, like so:
VB.NET:
xlWorkbook = xlApp.Workbooks.Open("C:\SQUID File for VBP Trends 2014Q4.xls")
it works as expected. If I refer to it as the active workbook (as it will need to work dynamically with whatever workbook its open in) the variable comes back as "Nothing".
VB.NET:
xlWorkbook = xlApp.ActiveWorkbook
Is there a way to make the variable "xlWorkbook" dynamically refer to whatever workbook is open?