Getting the WorkSheet names in a XLAM file

Rasm

Well-known Member
Joined
Feb 9, 2011
Messages
505
hmmm - I have installed a ALAM file as an add-in. I developed all the code in a XLSM file - in that file format the code below works. Next I save XLSM file as a XLAM file - however now the code does not work the same - in the sense that it does not the name 'NameXLAMworkbook' - so in XLSM mode - I have 2 workbooks - one containg code - the other containing data. In XLAM mode the WorkBooks.count is only one - when in truth it should be 2.

If I hardcode my 'NameXLAMworkbook' value - see after the 2 loops -then the code works fine. However - I like to be able to identify the version of the XLAM file - I do that adding a version number to the name. guess it brings up the entire question of how do you update XLAM file - do you simply overwrite the old XLAM file with a new version having the exact same file name.

Anyway - My main problem is how to get the Workbook and corresponding sheets included in the WorkBooks.Count and the resulting Sheet.count


Code:
  '**** Finds Name of XLAM file
    NameXLAMworkbook = vbNullString
    For i = 1 To Workbooks.Count
        For ii = 1 To Workbooks(i).Sheets.Count
            If Workbooks(i).Sheets(ii).Name = "Default_Settings_01" Then NameXLAMworkbook = Workbooks(i).Name
        Next ii
    Next i
    If NameXLAMworkbook = vbNullString Then NameXLAMworkbook = "PF_Data_Handler.xlam"
 
Just means you'll lose them if you overwrite the addin with a new version. IMO that's quite annoying for a user!
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,531
Messages
6,179,379
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top