Add In needs to get information from a Workbook

lostitagain

New Member
Joined
Jul 5, 2012
Messages
21
using excel 2010

I am attempting to create an addin that will allow a user to input information into a userform and then search a Source Workbook for a matching entry and copy it into the current Workbook. I can get it to work by opening the Source Workbook and copying the sheets and entries needed.

What I would like to do, if possible, is embed the Source Workbook into the addin itself so that I do not have to open up the workbook to get the information needed.

Any help would be appreciated.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
What actual help do you need? An add-in is just an Excel workbook so it has sheets so you could paste data from the source workbook into the add-in and then source your data from the add-in worksheet?
 
Upvote 0
I tried to include the macros in the source workbook and save it as an addin, but when I ran the addin it did not recognize any worksheets, named ranges, or information from the source workbook and I could not open the workbook itself to change the information in it.

I need a way to access this information that is faster than having the vba code open the Source Workbook anytime I need to copy a template sheet or search for and copy an entry from the source data. I also need to be able to update the information in the Source Workbook when new revisions are made.
 
Upvote 0
Assuming you have the add-in loaded in Excel, open up the VBE and navigate to it in the top left Project window. Click on its ThisWorkbook icon, and in the Properties window which should open below the Project window, set the IsAddin property to False. This will make the add-in workbook visible in Excel where you can manipulate the sheets & contents as you wish. When you have finished, just rest the IsAddin property, close Excel and confirm Yes to do you want to save changes.
 
Upvote 0
Thank you. That gave me access to the workbook again and works great for updating the information.

I stilll have a problem with the macros accessing information in the workbook though. Everytime I try to access the workbook, a sheet in the workbook, or a named range in it I get a Subscript out of range (Error 9).
 
Last edited:
Upvote 0
Do you refer to the activeworkbook and/or activesheet in the code? Add-ins can't by definition be the activeworkbook. Perhaps post up some code that exhibits this problem?

You would need to explicitly reference the add-in eg via:

Code:
ThisWorkbook.Sheets("SomeSheet").Range("A1:C100").Copy
 
Upvote 0
That's exactly what I was getting ready to post.

Code:
Set FromBook = ThisWorkbook
Set CurrBook = ActiveWorkbook

Now I can access the pages fine.

Thank you for the help.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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