How to save as excel and vba project for future use? - vba

How can I save as xlsx my project?
I try to do my project in excel with vba but I do know how to save it for future use.
If I save as excel sheet, vba will not be saved to it, I do know how to do that save.
Is there someone who has an idea to this problem?
Please anyone can help me.

xlsx only for data sheet. When you have VBA code in your excel workbook you should save as Excel Macro-Enabled workbook (*.xlsm)

Hello Schadrack Rurangwa**,
There a couple ways to do this.
Altenative One:
save the vba file to ".bas"
1. Click on menu Tools->Macro->Visual Basic Editor
2. This will open Visual Basic Editor
3. In the visual basic editor, select menu File-> Rightclick somewhere in the module and select export file. (save your module ".bas" somewhere).
Next time you start excel and want to use your VBA-Macro, just navigate to:
Tools>Macro->Visual Basic Editor> Rightlclick somewhere in the module and import the ".bas" file.*
Altenative two:
You could save the file Excelfile as "*.xlsm"
(A file with the XLSM file extension is an Excel Macro-Enabled Workbook file)

Macros can be stored in individual workbooks or available for a user in all workbooks opened if they are stored in C:\Users\nnn\AppData\Roaming\Microsoft\Excel\XLSTART\ PERSONAL.XLSB.
For more info see https://support.office.com/en-us/article/create-and-save-all-your-macros-in-a-single-workbook-66c97ab3-11c2-44db-b021-ae005a9bc790

Related

How do I activate an unsaved workbook using VBA?

The goal of my code is to run an online report, copy the data from an exported excel file and paste it back to the main file, and then manipulate the data.
The trouble I'm running into now is copying the data from the exported excel file. The online report exports the excel file as an unsaved "Book1" with one "Sheet1" with the data in it. I cannot seem to activate the exported file so I can copy the sheet.
I've tried
Workbooks("Book1").Activate
As well as using a for loop to iterate through all open workbooks (there are only 2 open workbooks, but the for loop only loops once - telling me that it isn't looping through the unsaved workbook).
Any help would be greatly appreciated. Happy to clarify any questions as well.
Thanks

How to crack the password for VBA modules in excel 2010

I have an excel 2010 macro enabled workbook for which I have forgotten the password. I tried the method of chaging the file extension to zip and then using the hex editor to change "DPB" to DPx". However when I reopen the xlsm file then excel will repair the workbook and the VBA modules are gone from the file.
Please suggest a way to crack the VBA module password. I used one of the method as per the below link :
Is there a way to crack the password on an Excel VBA Project?
Just open your excel file with a libre office!!(you can download it for free:
https://www.libreoffice.org/)
I have tried many times and works fine, open the modules without ask you for a password!!
Copy them and create a new file!!

Excel 2010. Automatically run macro from file with xlsx extension

I work with system, which automatically reads excel file, insets some date and sends to e-mail.
It works only with xlsx extension.
I need, that sending file have some format (borders and filling), so I would like to use macro.
How can I do, that macros automatically run from file with xlsx extension? Can I store macro in Person.xlsm file and run it when it is necessary?
Yes, macros cannot be saved in a .xlsx file. You can however use Workbooks.Open("filepath.xlsx") to open and edit another workbook from a .xlsm workbook. That is the way you should approach it.

A copy of Excel Addin is created in My Documents after saving

I have an application (running in IBM Notes, using Lotusscript etc.) that create a new Excel object via OLE automation. In my app I create a new Workbook and saving it to a temporary folder (I am saving it as Excel Worksheet w/o macros -> type 52) so that the resuting file is sth. like that:
tmp_abc1234.xlsx
Then I open the file in Excel programmatically. I have an Excel Addin (filename is "Teamoffice.xlam" loaded where some macros reside I will trigger in the custom save actionbar button. In this save method I also call the save function:
Call ActiveWorkbook.Save
Call ThisWorkbook.Save
For some reason Excel creates a file named "Teamoffice.xlsm" in the "My Documents" folder. The file itself cannot be opened in Excel ("wrong file format error") - of course, it's an Addin!
This works well if I have only one Excel document open from my application. If I open a second (or more) I run into trouble: everytime I save on of those secondary opened (or newly created) documents Excel asks me if I want to overwrite that "Teamoffice.xlsm" file.
I added VBA code to ma macro that detects if this file is there and tries to delete it. With no luck of course, as the first instance of Excel is locking that file already. Overwriting the file when aswering the Excel-question dialog works though, but I don't want that question to appear.
Excel doesn't behave like that when using it stand-alone w/o OLE.
Several questions resulting from this behavior:
Why does Excel create this file? Can I stop it from doing so?
How can I delete the file even if Excel has a handle on it or
Can I tell Excel not tohave a handle on this file (if it's there) and let me kill it?
Can I suppress the question dialog and always say "yes, overwrite it"?
Office version is 2010 - and it makes me going nuts... so thanks in advance!
p.s.: I am not that VBA pro, so please be as detailed as you can effort :-)
I noticed that
ThisWorkbook.Save
was the reason. If I omit it no file is created. Strange that this saved the Addin file as xlsm file though.

How to Make a VBA Excel Program Work on Other Excel Documents?

I'm very new with VBA Excel and i only know the things as far as i need for this report formatting task. My code is almost completed, but what i wonder is, how can i make my program work on several documents?
I mean, i want to choose an excel file via my program, then i want to start the process of report formatting. Then maybe user need to format another document, i want my program to be able to format that document too. how can i achieve that?
Thanks in Advance
Timur
The way I am currently doing this is by creating an Excel add-in. To do this, place your macros and forms into a new, empty Excel workbook and save as a .xlam document.
To use the macros, open the your Excel file and the add-in. To open the add-in automatically, save it to "C:\Program Files\Microsoft Office\Office12\XLSTART" (Vista).
You can even create a custom ribbon for your add-in using the Custom UI Editor for Microsoft Office http://msdn.microsoft.com/en-us/library/office/ee691832(v=office.14).aspx (The download link is at the end of the instructions)