According to the Microsoft website, a macro is a series of commands that you can use to automate a repeated task, and can be run when you have to perform the task. Microsoft applications currently use Visual Basic for Applications (VBA) programming language to build their macros, and they allow you to choose whether you want to enable or disable existing macros from use. If you open an Excel file and receive a notification that macros are present, the following API will identify the macros and let you decide if they are safe to enable.
To use this API in Python, we will first install the client:
pip install cloudmersive-convert-api-client
After the installation, we will call the function with the following code:
from __future__ import print_function
from cloudmersive_convert_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_convert_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_convert_api_client.EditDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))
input_file = '/path/to/inputfile' # file | Input file to perform the operation on.try:
# Get macro information from a Excel XLSX/XLSM spreadsheet, worksheet
api_response = api_instance.edit_document_xlsx_get_macro_information(input_file)
except ApiException as e:
print("Exception when calling EditDocumentApi->edit_document_xlsx_get_macro_information: %s\n" % e)
In no time at all, you’ll receive your macro information results. To obtain your API key, head to the Cloudmersive website to register for a free account; this will give you access to 800 monthly calls across our ever-growing library of APIs.