I've tried to create macros in OnlyOffice Desktop Editors version 7.0.1.37 and they seem to run just OK.
But every time I create a new file, macro plugin cease to show previously created macros.
This is what is quite different from that of Microsoft Office and Libre Office where macros stored usually in a common place, available from the menu and nicely organized in Libre Office.
Is there a similar option in OnlyOffice?
Copy-pasting macros seems tedious.
Related
I recently wrote a form in VBA for Outlook and saved it to my personal form folder.
Now this form should get exported in a userfriendly fashion. What is the best practise here?
I know that you can go to File -> Export file... in VBA, but this seems to have caused some problems in the past and doesn't seem very intuitive to use both the frm and the frx files.
The form is supposed to be accessed by employees to book their holiday.
That is COM add-ins were invented for. They are designed to be installed on multiple machines and users. VBA macros are not designed for transferring the code - the infrastructure doesn't provide anything for moving solutions automatically like you could do in case of COM add-ins. You need have do that manually in VBA.
If you consider moving your solution to the add-in rails, see Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly. You may choose VB.NET which has a similar syntax with VBA.
Background and Problem
I lead a team of tech writers. Our team has a Word template (.dotm file) that has a bunch of VBA macros we've created over the years to help us automate tasks in Word. The macros are obviously stored inside of a .dotm template. Given that the code is stored in a binary file, the code is not easily traceable across commits.
Currently, we have to pull the changes on the branch and then open the macro inside Word's embedded code editor from the .dotm. But there's no way to see what exact code changes someone else made line by line or resolve conflicts using something like Beyond Compare.
What I Need
I'd like to find a way to automatically expose the VBA code from the .dotm as some kind of text file so that we can:
Do Word VBA coding tasks within VSC
Easily track and review each others code changes at the line level using our git repository
Resolve merge conflicts more easily
Has anyone found a way to do this?
What I've tried
I've tried searching online and on stackoverflow.
Hoping it might help, I installed ScriptLab, and I after following the MS tutorial, I now have Office Add-Ons working with VSC.
(https://code.visualstudio.com/docs/other/office),
(https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/word-tutorial) While the Office Add-Ons through VSC does provide an alternate (more modern) way of automating using Javascript, and the .js files are commit-able, it's not providing a way to expose the Word VBA, at least not that I could see.
Thank you in advance!
ScriptLab add-on is for playing with JavaScript code instantly, not designed as a macro infrastructure in Office.
Sounds like you need to switch your VBA macros to COM add-ins rails. There is no converters that can do this part of work for you automatically.
You may consider creating a VB.NET based add-in. In that case you will avoid language translating issues. You may find the Converting Code from VBA to Visual Basic .NET article helpful. It presents issues to consider when converting your Microsoft Office solutions from Visual Basic for Applications (VBA) to Visual Basic .NET. Provides a general overview of their differences, and then uses examples from Word and Excel to describe how you can use Visual Studio Tools for the Microsoft Office System to convert your code.
Trying to save a MS Word macro as an add-in, fully independent, portable and installable as a word tool. What kind of literature should I consult to learn this technique?
So far I've tried looking on Google and StackOverflow. Many people ask similar questions, no one seems to provide a valid answer.
In the end, I would like to be able to export a macro in the form of a exe/batch/whatever to be summoned/installed from word and customize the tools ribbon permanently, to conceal the macro sourcecode and easily propagate to other machines.
It's not possible to use VBA macros as exe or batch files. It is possible, however, to load a macro-enabled template as an add-in. All the functionality will then be available (Ribbon, keyboard shortcuts, macros, building blocks).
Save the document as a dotm file (template, macro-enabled)
Copy the file in the STARTUP folder. Word will then load it automatically.
For a "real" add-in that uses the same COM object model as VBA it's necessary to build software based on the IDTExtensibility2 interface. There are number of tools that use this, making things easier. Microsoft's VSTO (Visual Studio Tools for Office) is one that costs nothing.
Another alternative is to use the newer Java Script APIs for Office. These are, in the case of Word, incomplete as far as functionality for the object model is concerned (can't do everything the COM object model is capable of).
My company will be changing from Excel to Libre Office Calc. I have built up a collection of Excel VBA Macros (especially screen scrape macros). Will my Macros work without changes? Anybody else that has made the change, how do you make the change smoothly?
Possible already answered by Rubber Duck https://stackoverflow.com/a/24749320/7326037
From LibreOffice's online help file:
With a few exceptions, Microsoft Office and LibreOffice cannot run the
same macro code. Microsoft Office uses VBA (Visual Basic for
Applications) code, and LibreOffice uses Basic code based on the
LibreOffice API (Application Program Interface) environment. Although
the programming language is the same, the objects and methods are
different.
The most recent versions of LibreOffice can run some Excel Visual
Basic scripts if you enable this feature at LibreOffice -
PreferencesTools - Options - Load/Save - VBA Properties. In reality,
you would most likely need to sit down with the LibreOffice API and
rewrite the functionality.
This post also suggests that at parts of the VBA macros will work but will require a bit of manual migration.
https://ask.libreoffice.org/en/question/6621/import-ms-word-macros/?answer=6982#post-id-6982
In ODF/ODS files you have to enable VBA support at the beginning of the macro, otherwise it expects LO-Basic:
Option VBASupport 1
Option Compatible
Ultimately, you're probably going to have to go through each one and check that it functions correctly.
In most cases this won't work without converting the macros from VBA to Libre Office Basic. You will need to rewrite them and test them before you perform the switch to Libre Office to make a smooth switch.
I'm currently working on an vba project to help document developers do their work better and faster.
The tool is helpful during the developing, but however, it's no longer needed after the document is complete.
So, is there any ideas, about how to export a pure document without vba code automatically? Or shall I do this stupidly by opening vba and remove all of its code?
Further more, Is there any ways, to automatically apply vba code to an existing document?
You can create an add-in. Your VBA code lives in the add-in, but operates on your documents. The add-in can create a custom menu to run your various routines.