Save word file with VBA userform and macro - vba

I created a VBA userform with some functions and running it with a macro and saved it as a .docm file. But the problem is when I am trying to run that docm file from another computer, nothing is working. And later when I checked the VBA code, I saw my userForm1 was not there. I have no idea what is going on there. How to solve this issue, so that I can run my VBA form into another computer ?

Though I got a solution. But I dont think this is ultimate one. Solution is load those forms and macro into a dotm file by clicking Macros Menu>Organizer>Transfers all forms and macros into that dotm file >save the dotm file. And when you need to restore it into another computer, just reverse the process and store those into the Normal.dotm file.

Related

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 call a VBA-macro in another MS Word document?

in MS Excel I have been distributing a xls-file that contains a macro. From the users "random" current open workbook I have successfully been calling this macro by telling Word in which file to look for it. Like this, when the user clicks a button on the ribbon:
C:\\"'MyExcelFileWithTheMacro.xls'!MyMacroName"
Can I do the same in MS Word?
That is, to call a macro in a Word-file located in any given folder from an instance of Word that has not opened that file?
I have tried, of course, but Word keeps saying it can't find the macro.
The reason I want to do it this way is that it is makes for easy distribution and updating of the macro. Next up is signing the macro. I hope it can be done when doing things this way, but not sure.
No, it's not possible to call and run a macro in any Office application if the file that contains the macro is not loaded in the application interface.
That being said, if you place the macro in a *.dotm template and have the user put the template in the STARTUP folder used by the Word application, then Word will load the template as an "Add-in". And in that case you should be able to access the macro.
Or, if you don't want it in the Startup folder and you have code that automates the Word.Application, anyway, then that code can load the *.dotm as an "Addin", which should make the macro available (and remove it when you're done with it). Research Application.Addins.Load and Addin.Installed in the Word language reference as well as on-line for examples.

Macro not responding on different computer

I have a macro which works fine on my computer when I click its button but it does not work on different computers.
All the macros on that excel file are not working when clicking on the button.
However, I have a macro working before saving. That means that when I try to save, another macro works properly. (that macro pop up an input message, but is not relevant now). So it seems that macros are not working only when you call them by a click...
The version of Excel is the same one and I enabled the macro when asked.
It is not a problem of the code because even if I create a new simple macro on that file from the different PC (such as:
msgbox("hello")
) it is still not responding.
I had a problem with that excel file in the past and I had to manually delete all the *.exd extensions in my computer. However once I deleted those extensions, the file worked well.
I believe that the excel file is considered corrupted by other computers and they do not enable the macro. This is just my impression but I cannot get why the macro is working when saving and not working when clicking.
Do you have any idea to solve the problem?
I had issues like that myself both with macros and with Excel workbook doing some really funny stuff (like formulas not calculating properly, or functions not working as expected etc) and I did not find any other solution then copying the content of the file and pasting into a newly created file.
In each case this resolved my problem.
It suggests that my files somehow got corrupted and the only solution was to save the contents and delete the files.
Exporting the .frm and .frx files from VBEditor (Modules and Forms) worked fine for me.
Have you tried this yourself?
This may be too simple a suggestion, but have you checked the security settings in Excel? The other computers may be set to a higher security setting that disables all macros without notifying the user.
https://support.office.com/en-US/Article/Enable-or-disable-macros-in-Office-documents-7b4fdd2e-174f-47e2-9611-9efe4f860b12?ui=en-US

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.

Excel - "File Not Found: VBA6.DLL"

I have an Excel 2007 Sheet with Macros. When I click on a button, it immediately pops up an error "File Not Found: VBA6.DLL"
Problem is, I have been using this sheet forever, and never seen this problem before. I did make some very very minor changes to the Macro code.
And, I have 2 other sheets with identical macro code which I made the same changes to. And those two sheets run fine.
Any ideas?
In this order:
Check your references (Alt+F11, Tools-References) to see if any are marked MISSING and make sure that Visual Basic for Applicatiions is checked.
Check the directory C:\WINDOWS\system32 for VBA6.dll
You may need to register VBA6.dll (Start->Run)
Regsvr32.EXE "C:\WINDOWS\system32\VBA6.dll"
I had the same problem with a shared file. The fix was as follows:
Un-share the file
Copy all macros; sheets, this workbook, modules and saved them in a text format.
Save the .xlsm as a .xlsx file
Save back to .xlxm file
Paste all macros back in
Reset shortcut keys and descriptions in macro options
Re-share the file
This worked without having to go to IT and get someone with administrative credentials to fix it.