Hiding or not displaying excel VBA UDF module/code - vba

I wrote a simple UDF in Excel VBA. I saved it as an Add-in and imported it in so that I can use the function like any other excel function. But whenever I open an Excel workbook and subsequently VBA window to create a macro, the module I wrote is displayed in the Project Explorer window and its code in the coding window.
Is there any way I can hide or not display every time I open VBA?
Please let me know if you need more information. Thanks in advance!

Related

open custom ribbon in other workbook VBA

I am writing some vba in excel to create another excel report.
This report needs to have adjusted the header /footer, which my company have through their own custom ribbon in Office.
If I am in my main workbook, I am able to activate the ribbon by following code:
Application.SendKeys ("%HY2%")
But after I created my excel report it seems like the custom ribbon is not given time to activate or something.
I then call the report like this
code:
Workbooks.Open Filename:="C:\Users\ccc\sss.xlsx"
and then try
code:
Application.SendKeys ("%HY2%")
Then it is possible to call the Home tab, but not the custom one.
I have tried to delay the code using wait function, sleep function and Do While (check if ready)
But during all these, it seems like excel tabs is on "hold", it is not activating the custom ribbon. Therefore my code opens the Hometab, but it cannot find "Y2" Ribbon.
I have tried activating the main workbook to do some random code, then going back again and activating the report again, but no...
Can anybody help please?

Retreiving/reading excel macro without opening excel?

I wrote an excel macro that seems to have broken, unfortunately when I try to edit the macro in the VBA editor, excel itself crashes spectacularly. This seems to happen whether I open the VBA Editor before or after loading the problematic excel file.
Does anyone know of a way of viewing the VBA code that I've written without using excel to get there? Alternatively, can anyone get to the VBA code in (this excel file)(Link Removed) without it crashing their excel?
Unlike "Running Macros without opening excel" I don't need to be able to run the broken code without excel - just copy and paste it somewhere to fix it!
I created a fresh new excel file and open the VBA editor. Then I opened the one you provided, but I had put it in a non-secure folder. Excel prompted me the choice of opening it with macros disabled. I did, and I could see the code in the editor. :)

How to open add-in automatically on opening excel workbook

I want to know how I can have a workbook automatically open an add-in? The problem is after I create the workbook in code -- call it "A.xlsx" -- I want to add code to it (on creation) that will open the Excel add-in "B.xlam". How do I do this? Creating the workbook is no problem; that part is sorted, and I just want to add the code to that workbook, so that every time it opens it must open the add-in "B.xlam" with it.
From the Developer Ribbon, click Add-Ins,
then click Browse, then navigate to the location of the desired add-in file, then select it, and make sure the checkbox is selected for it.
Alternatively, store the code in PERSONAL.XLS/PERSONAL.XLSB, and these macros/functions will be available to all open workbooks.
If you're somehow asking how to programmatically insert code in to new workbook files, I'm afraid you're out of your element. If you don't know about the Workbook_Open event, nor how to manage your Add-Ins, etc., manipulating the VBE is a pretty high-level operation, and I would not be able to help you with that.
Update from comments
Here is one method that will export VB Components to a specific path, example also includes code to import modules from path to a workbook. You should be able to adapt this to your purposes.
http://www.rondebruin.nl/win/s9/win002.htm
If you have specific problems implementing this solution, please post as a new question.

Display Excel inside VB6 / VB.NET Form & work with Excel without excel menu

I have an Excel sheet with Macros enabled. I want to display the Excel sheet inside a VB6/VB.NET form without excel menu header and perform excel activities inside the form.
Please note that I need to perform some macros actions when some cell is entered...
My Objective is to create a standalone VB6/VB.Net Form in which excel cells should be displayed for performing marco actions.
I have tried searching for any sample but no luck. It should be something like this...
Can any one hint me to achieve this ?
As far as I can tell - this is not possible. The reason being that you cannot subclass the excel window in VBA.
If you program outside of excel with VB.NET or VB6 it would be sort of possible, but would probably not work really good.
If you only want to display some data from a sheet and perform some small actions on them, you could probably read the Data via the EPPLUS Library, display them as a datatable (EPPLUS can convert between datatable and excel files), perform your actions and save them to the file afterwards. But this would only work in VB.net
I did a lot of research into this last year. There is no available package to do what you are asking that is provided by MS or for free, however, you could create a datagridview (DGV) in vb.net and load the data into the DGV via ADO.NET. The data loaded into the cells will mirror your spreadsheet. Then when you modify the cells in the DGV, have a label as you have shown to update the data changes back to the excel sheet.
http://social.msdn.microsoft.com/Forums/en-US/7a1c828d-04ed-4a8d-927d-3649f29d2060/import-data-from-excel-sheet-into-datagridview
As far as calling the macro, use the excel interop feature to call a macro:
http://social.msdn.microsoft.com/Forums/office/en-US/2e33b8e5-c9fd-42a1-8d67-3d61d2cedc1c/how-to-call-excel-macros-programmatically-in-c
There may be some third party support for what you are doing, but of course it costs money:
http://www.componentone.com/SuperProducts/SpreadStudio/?gclid=CLKIy6TqwLkCFYZlOgodhToAZg

Excel VBA - Call macro using add in

I have added a toolbar menu for my macro, so I can just press the button and it runs my macro from any excel document. Every time I run the macro though, it opens the source file containing the macro. Is there a way that it won't open the source file and just run the macro? (even opening and closing wouldn't too much of an issue, but I'd prefer not opening it at all)
I haven't been able to find any information about this, so all help to get me started is appreciated.
You can't pull code out of the air to run it; Excel's going to have to open the file the code's stored in to run the code.
If I understand it correctly, you can create an Excel add-in from your code and have the add-in load automatically when Excel starts. Your code will always be available in that case.
This seems like a good place to start:
http://msdn.microsoft.com/en-us/library/aa140990(v=office.10).aspx
USE YOUR PERSONAL MACRO WORKBOOK
Open the VBEditor and find the module containing your macro.
Copy that code.
Now in the VBProject Panel on the left, locate your PERSONAL.XLS or PERSONAL.XLSB project. This is the project where you store macros you want available at all times. Add a module to that project and put your code into it.
Now update your "button" so that it points to the macro in that workbook and you're good to go.
On the off chance your PERSONAL.XLS project does not exist, use the macro recorder to record a "junk" macro and be sure to set it to "Store Macro In: Personal Macro Workbook"... that will create it for you the first time.