Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This has been fixed. The problem was the file extension. Some code like
this, in the Workbook_Open event solves the problem: If ThisWorkbook.IsAddin Then g_sMyWbName = "example.xla" Else g_sMyWbName = "example.xls" End If then later... Dim xwb as Excel.Workbook Set xwb = Application.Workbooks(g_sMyWbName) Thanks again... "S. Daum" wrote in message ... Thanks for all the replies. I am closer to a solution but not there yet. In haste, the example I originally posted disguised/confused my real problem. I am trying to get a reference to the "workbook" that IS my "add-in." This workbook contains two "worksheets." Here is a more precise code snippet: Dim xwb as Excel.Workbook Set xwb = Application.Workbooks("MyAddinWorkbook.xls") The reply about an add-in having an .xla extension may be the answer? I am in the process of trying this but I am temporarily "broken" for other reasons. As I mentioned this works when I have MyAddinWorkbook.xls open within Excel but fails when running as an add-in... About the replay saying I could set ThisWorkbook.IsAddin = False - will this not then display my workbook as any other workbook? I would like to avoid this if possible. Thanks again for the replies. Steve "Harald Staff" wrote in message ... A workbook is made up of many worksheets. So when you say that a worksheet is a workbook then you ask for trouble. -- HTH. Best wishes Harald Excel MVP Followup to newsgroup only please. "S. Daum" wrote in message ... Dim xs as Excel.Worksheet Set xs = Application.Workbooks("MyCodeWorkBook.xls") |