I have attached an example of what i am working on.
im having a few issues with the macros, they are normally attached to open office not the document so no matter what doc is opened the macro is ran if i can find a solution to issue 1 i dont need solutions to the other 2 issues.
issue 1. macro errors are my biggest problem. what i want to do has the macro exit sub on errors so that when there is an error it wont display my code to the user.
issue 2. I want the startup macro to only open when the document is first loaded but if i attach it to event documentloadfinished oo waits for the macro to finish before creating the view causing the macro to return an error message, if i attach it to event documentopen it doesnt load the macro at all, if i attach it to viewcreated it crashes oo when trying to go into page/print preview, so i attached it to documentactivate but it loads the macro each time the document comes back into active view. so i changed the macro around to compensate for this error, but i would like it to load each time the document is loaded instead of only the first time.
issue 3. if a doc is saved in page preview or print preview or pagebreak preview it opens up in that view causing the macros to return errors and display my macro. im working with not so smart people that freekout when this happends, i have added a check system to check doc type before loading i would also like it to check for correct view or change it to correct view but i have yet to create a macro that will close the page preview(not pagebreak preview) so the macro may read the required cells on startup.
the macros are stored on oo and not the doc because the doc is sometimes sent to another computer and when this happends macros are disabled or have errors so i have configured each computer with macros in oo that respond to the documents that are loaded.
[Solved] Help with macros
[Solved] Help with macros
- Attachments
-
- EXAMPLE PAGE.ods
- all macros in this document are save to run, you dont have to take my word on it though your welcome to look at them before hand
- (59.86 KiB) Downloaded 444 times
Last edited by MATT.B on Fri Sep 04, 2015 2:45 pm, edited 2 times in total.
OpenOffice 4.1.1 ON WINDOWS 7 64
Re: HELP WITH MACROS
Hallo
Bullshit - that Stuff refers to exactly this doc - so store the macros into the doc.the macros are stored on oo and not the doc because the doc is sometimes sent to another computer and when this happends macros are disabled or have errors so i have configured each computer with macros in oo that respond to the documents that are loaded.
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Re: HELP WITH MACROS
Cant store macros with the document some computers are running excell and some oo the ones running oo have oo macros in oo and the ones running excel have excel macros where the macro is stored does not effect the answers to my question each computer is configured with diferent user names and macro signing doesnt transfer from computer to computer that and the doc is a template and i dont want the macros saved to the finished copy. it is set up so depending on what sheet is opened it will auto save on oo exit with out prompting the user for file destination or file name so if they forget to save it will save for them in a folder that is shared on the network but each computer is configured differently so the destination for the file is always different. on each computer i have configure this macro with slight changes to prevent errors and such also i have created 6 different documents that use this macro depending on what number is located in zz1-zz3 (for instance if zz1-3= 5555 it disables the path and filename and just saves on exit, it also prints sheet 1 page 1 and 2, sheet 2 page 1 and sheet 3 sets pagebrakes at certain points and prints all pages. if zz1-3 = 5615 it sets mypath/myfilename to a folder on the computer opening the doc saves and exports pdf version (still working on bugs for pdf export)if zz1-3 = 5616 it saves on close and sends it to an e-mail. i havent included the other codes no need the code im having isses with is when checking zz1-3 on calc documents if the view was saved other than normal view.
OpenOffice 4.1.1 ON WINDOWS 7 64
Re: HELP WITH MACROS
I have mistaken they are not stored in openoffice macros but in my macros in openoffice
OpenOffice 4.1.1 ON WINDOWS 7 64
Re: HELP WITH MACROS
For the loading: If you were only working in Calc, I would say to create a form inside your Calc document and attach the macro to the form's "When loading" event. (To create a form, open the form navigator, right-click on the work "Forms" and choose New->Form; to open the form navigator, press the sixth icon from the left or top on the toolbar "Form Design" - the icon looks like a rectangle with a compass in the upper right corner; if the form navigator icon is grayed out, the first press the design mode on/off icon all the way on the left or top, looks like a triangle with a pencil) In the form navigator, right-click on the form's name and choose "Properties", then go to the tab "Events" to see the events you can attach a macro to.
I'm not sure how Excel would react to opening a file with a Calc form in it, though.
For getting out of print preview mode, have you tried the dispatcher call .uno:ClosePreview? From reading this thread you may have to add a wait into your code somewhere to prevent crashing.
I'm not sure how Excel would react to opening a file with a Calc form in it, though.
For getting out of print preview mode, have you tried the dispatcher call .uno:ClosePreview? From reading this thread you may have to add a wait into your code somewhere to prevent crashing.
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
Re: HELP WITH MACROS
because of the difference in the programs I have actually crated 2 docs one for oo and one for excel ill give that a try and see how it works
OpenOffice 4.1.1 ON WINDOWS 7 64
Re: HELP WITH MACROS
I don't understand this step where and I right clicking I mean I know how to open all the form toolbars but this step CONFUSES MEMTP wrote:(To create a form, open the form navigator, right-click on the work "Forms" and choose New->Form;
ok I like I actually think I figured this out on my own I just used form navigator to create the new form
Last edited by MATT.B on Thu Aug 27, 2015 2:15 pm, edited 1 time in total.
OpenOffice 4.1.1 ON WINDOWS 7 64
Re: HELP WITH MACROS
No that is the command I think I have been looking for I learned basic on excel by messing around with it still new but I can do some cool stuff with it but switching to oo the communication commands are very different even a little more complicated thank youMTP wrote:For getting out of print preview mode, have you tried the dispatcher call .uno:ClosePreview? From reading this thread you may have to add a wait into your code somewhere to prevent crashing.
OpenOffice 4.1.1 ON WINDOWS 7 64