If I try to use a document event but it works only in Untitled ones. After save, when I reopen it I am asked about enabling macros, I press Enable but nothing happens. Any of its events do not work. In IDE the name of the file does not appears in parenthesis after VBAProject (in case of events existing)... It looks it is hidden. I mean enumerating VBAProjects in VBA, its name appears like being a VBProject.
Is that a general problem of X8 (maybe a strange security one...) or only my installation has a problem?
Is it something to be done in order to activate events?
I tried some workaround which works but also in strange circumstances. I use a reference at 'Microsoft Visual Basic for Applications Extensibility 5.3' and that gives me the possibility to programmatic copy an event from a document/GSM to another document. When that document does not have a path (type Untitled) it works. If I save it all event code stays there but stops working. If I copy such an event in a document (saved) not having VBProject (not any VBA) it is not working, too.
Another annoying issue is the next:
If you save a document having an event code and after that you delete that code, somehow some VBA garbage remains inside that document. When I open it I am prompt about macro Enabling, even if not a line of VBA code exists any more. On top of that, if you have a big document with more then 100 pages, that in-existing VBA project (garbage) loads first and the document itself loads only after that. You cannot see the message asking about Enabling macro. If you call a function from a button outside VBE, CorelDRAW crashes... In such cases I learned it is necessary to play with Ctrl + Tab until I find the message about macro Enabling and press one of its buttons. Otherwise corelDRAW crashes...
Is there a way to clean the document of its VBA garbage in order not to be prompted regarding macro enabling?
Thanks in advance!
P.S. Any idea about whatever issue presented here will be well appreciated, even strange approach will be presented...
I tried the events in the document I offered to you also on my laptop where I also have Corel installed on D:\, and there it also worked like described.I did also more tests and came to that conclusion:Something happens, when you open the VBA-Editor (or activate the macros the first time). If you open one or more documents with events nothing happens unless you open the VBA-Editor. Then the events for the open documents work. If you open a document after the VBA-Editor had been opened, the events for this document will not work, but the events for the previously opened documents.In my use case the preconditions are given: My batch takes care, that the needed documents are open. Then - when I move the mouse the first time over my icons - I get asked (due to my macro security setting 'Medium'), if I trust the macros. I think, this step will do the same as I do when I - without Macro-security -open the VBA-Editor for the first time.Maybe you check, if this behaviour is also valid in your environment.I already opened for this behaviour a ticket, maybe you do the same, so the probability that they will change this is higher Regarding the 'VBA-Garbage': I can not remember that I had the need to remove VBA-Code from a document.
Maybe my way of programming is slightly different to yours, I also don't know, if this method is possible for your tasks:When I have the need to create more pages under Corel, I always work with two documents: One Document containing only the macros with in general only one page with default layers. This document then creates a second document with many pages I have then e.g. to print. So my documents with VBA-Code are pretty small, the other containing a lot of graphics over a lot of pages may become huge, but I need only to open then for the current session, but do not need then in general later. So my program documents are not affected by the size of their output.
Maybe you think about this method before you start your next project.
I tested in the way you suggested but events do not work in any circumstance! I tried it with Security Low level but also for nothing.
I do not use macros in big sizes documents. I have one document with labels containing more then 100 pages. In order to make the labels I use an automation of course. In a GMS file I have a form which needs to have some text boxes updated with page sizes when a different page is activated. I do that writing (on the fly) code in the document pageActivated event. This code is able to write in the Form text boxes. After doing the job I delete the code but some VBA garbage remains so each time I open the document, even if it does not contain any line of VBA code I'm prompted to enable macros or not...