How to call macros using azure api - excel

I have an excel file containing around 100K rows in onedrive. This file contains some macros. I want to run these macros using api.I want to pass these macro functions as parameters.
For example
https://graph.microsoft.com/beta/me/drive/root:/book1.xlsx:/workbook/tables/{id|name}
Here, I want to call macros function in place tables/{id|name}
Any way to do this?
Thanks

To be able to run an Excel macro, you need a running Excel instance that opens the file containing the macro and runs the code. There is no way around this I'm afraid.
So you need a machine - physical or virtual - where Excel is installed. Then you can have a script open the Excel file there and run the macros.
If you are working in a cloud environment or on a web server for example, you would be better off rewriting the code in another language, independent of Excel. (Trust me, I've been there, done that.)

Related

BAT script to automate importing VBA modules (.BAS) into Excel file and running macro

I've been trying to search for similar questions but wasn't able to find much for precisely what I'm looking for. I could have missed it in my search - if any of you can find a previous thread for this, please link it for me :)
Essentially what I'm trying to achieve is to fully automate an Excel report, which involves running a macro that I have a .BAS file for. I've seen tutorials for how to create a .VBS and .BAT script to automate the running of macros, but I wan't to also automate the importing of the macros. For example:
- I have my base dataset that I want to run the macro on, which comes in a standard Excel file (xlsx), which I save in a consistent location
- I have my .BAS file which contains the macro I want to use every time, saved in a different location from my reports
- What I am seeking: to have a .BAT file on my desktop that will automate: 1) Opening my standard xlsx file, 2) Saving it as an xlsm, 3) Importing my .BAS file with my macro, 4) Executing the macro, and 5) Closing Excel.
The key part I am missing is how to have the .BAT script automatically import the .BAS module into my Excel file. If I have to manually open Excel and import the module, I might as well just manually run the macro as well, thus eliminating the purpose of trying to create a .BAT file to automate :)
If anyone can provide guidance, that would be much appreciated. I hope my post was clear - if any questions, I can clarify in comments.

Add-in macro conflict Excel

Initially I have 1 function: CusFun in an Add-in1
I copy all code in Add-in1 into module in Excel file, save file 1.xlsm
I open 1.xlsm to work, now I have 2 functions CusFun
I changed the name (and only the name) of the functions in macro in module1 in 1.xlsm as CusFun_Port
Now I have 2 UDF: CusFun and CusFun_Port when I work with 1.xlsm
But CusFun_Port (all of them) always return blank while CusFun work normally.
Why use macro-enabled file instead of add-in? Because I need to send the file to many users back and forth. I initially thought only I use them, using add-in save me the trouble of clicking "Enable content". With add-in, every computer use it must install it. And when the file is sent to another computer, all the custom functions in the file must be re-targeted to that computer's add-in location. My users are not proficient in any of those tasks. And those tasks takes far more time than clicking "Enable content".
What can I do to make sure that both functions in add-in and file-specific macro work?
Finally, I found it. Because I change only the name at the top of the function, it doesn't work. Because all of them are recursive, the function's name inside did not change, hence it doesn't work. There is no conflict here.

Excel 2013: Macro Version Control Strategy

We are using TFS as source control system and I would like to implement the following:
We have Excel files on multiple workstations (all connected to TFS) that shall always use the latest version of a macro.
Therefore, I thought about somehow defining the macro in an external file which is under source control and can be centrally maintained and mapped to the local workspace of the workstations where the Excel files are located.
Within the VBA section of the Excel files, there should only be a link to that file so that always the latest version of the macro is used (assuming that the user made a GetLatest operation on the external file containing the macro).
Is a scenario like this technically possible? If yes, how can I define that the Excel file has to import the macro from the external file?
If I understand you correctly referring to the macro containing file as an Addin should do the job.

Open MS Excel by Matlab

is there a way how to make Matlab open excel files directly in MS Excel? I do not mean just read data, but physically open MS Excel.
I have a script that processes some data and saves it into .xlsm. This .xlsm contains auto_open macro which generates a report and saves it into another .xls.
I want the process to be as automatic as possible. So far, when the matlab script ends, .xlsm file needs to be open manually. Is it possible to do it via Matlab? (The .m file and .xlsm are in the same folder.)
The simplest way to open (but not close) an Excel file is to use WINOPEN:
winopen('myFile.xlsx')
Excel has a powerful COM interface that lets you control it from another application.
Look here for the matlab side of things
http://www.mathworks.co.uk/help/techdoc/ref/actxserver.html
And here for an example of putting it all together . . .
https://www.quantnet.com/forum/threads/interface-between-matlab-vba-excel.2090/
or here is another example
http://www.mathworks.co.uk/support/solutions/en/data/1-716EAM/index.html?solution=1-716EAM
Yes, it is possible. Matlab can use Excel's Automation interface to do this and similar tasks. The following code loads Excel and then loads a workbook:
try
w = actxserver('Excel.Application'); % Fails if Excel not installed
catch
w = [];
end
if ~isempty(w)
w.Workbooks.Open('D:\Documents\MATLAB\file.xlsx');
% Your code here;
w.Quit;
end
delete(w);
You will need to look at Microsoft's documentation for the Excel automation interface to figure out exactly what commands you need to send. Try starting here.
I have used this technique to drive Word from Matlab in order to produce a report document, but I have never used Excel this way, so unfortunately I can't help you with the gory details!

Is this possible in Excel: Open XLS via commandline, OnLoad import CSV data, Print as PDF, Close Doc?

Thinking that to solve a problem I've got this is the fastest solution:
Generate a custom CSV file on the file (this is already done via Perl).
Have a XLS document opened via commandline via a scripting language (clients already got a few Perl scripts running in this pipeline.)
Write VBA or record a macro that executes the following OnLoad:
Imports a the data from the CSV file into the report template,
Print the file via PDF driver to fixed location using data in the CSV to name the file.
Closes the XLS file.
So, is this possible via Excel macros, if not is it possible via VBA -- thanks!
NOTE: Appears I've got to have a copy of MS Office anyway, so this is much faster to get going than using Visual Studio Tools for Office (VSTO). The report template is going to be on a server, and this way the end user can build as many reports as they like, "test" by printing a PDF using a demo CSV file, and import/embed the marco or VBA when they're done. I'd looked in Jasper Reports, but the end user is putting ad-hoc static text and groupings all over the report and I figure this way they can build reports how ever they want and then automate them. Both of these questions by me and the resulting comments/feedback are related to this question:
In Excel, is it possible to automate reading of CSV data into a template and printing it to PDF from the commandline?
Is it possible to deploy a VB application made in Excel as a stand alone app?
FOCUS OF QUESTION: Again, focus of the question is if this is possible via Excel marcos, if not macros VBA, and if there's any huge issue with this approach; for example, I know this is going to be "slow" since Excel would be loaded per job, but there's 16GB of ram on the server and it's not used at all. Figure since I've got to have a copy of office on the server anyway, this is a much faster approach.
If you've got any questions, let me know via comments.
I suppose you could launch the report file from perl and then have a macro inside the report file automatically look for the newest csv file to import. Then you could process and output. So you just need to launch the proper excel file with the embedded macros from perl and then let excel and VBA take over.

Resources