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...
This also appens in CorelDRAW 2017. I have a Template with some VBA code and crashes CDR if I save with the macros and then try to re-open the file.This issue comes from X8.
I'm trying to get to a solution too, if I came up with something i will post it here.
In my previous X7 installation, document events Worked!
If it crashes I am afraid that your code contains something bothering Corel. If not confidential can you post the code here?
The is that my Template is now without any code.But I still have the option to "save with embeded VBA project"
Here is my code:
Private Sub Document_BeforeSave(ByVal SaveAs As Boolean, ByVal FileName As String) Dim ano As String ano = Year(Date) ActiveDocument.Metadata.Title = ActivePage.Layers("Obra").Shapes("NObra").Text.Story.Words(1) ActiveDocument.Metadata.Subject = ActivePage.Layers("Obra").Shapes("Cliente").Text.Story ActiveDocument.Metadata.Keywords = ActivePage.Layers("Obra").Shapes("Cliente").Text.Story ActiveDocument.Metadata.Author = ActivePage.Layers("Obra").Shapes("Desenhador").Text.Story ActiveDocument.Metadata.Copyright = ano + " MyCompany"End Sub
Private Sub Document_PageActivate(ByVal Page As Page) ActiveDocument.WorldScale = 0 & ActivePage.Layers("Obra").Shapes("Escala").Text.StoryEnd Sub
Like you know I cannot test any event in a document so I think and work blind...
Firstly you must check if your event is fired. Change everything with just MsgBox "It works..."
If it works I'm just thinking maybe is possible that the layer not to keep its name. So I would suggest to check that prior to the main code working:
Dim ano As String, L As Layer
ano = Year(Date)
For Each L In ActivePage.Layers
If L.Name = "Obra" Then
ActiveDocument.Metadata.Title = ActivePage.Layers("Obra").Shapes("NObra").Text.Story.Words(1)
ActiveDocument.Metadata.Subject = ActivePage.Layers("Obra").Shapes("Cliente").Text.Story
ActiveDocument.Metadata.Keywords = ActivePage.Layers("Obra").Shapes("Cliente").Text.Story
ActiveDocument.Metadata.Author = ActivePage.Layers("Obra").Shapes("Desenhador").Text.Story
ActiveDocument.Metadata.Copyright = ano + " MyCompany"
If the layer will be found the code will stop and please press F8 in order to see the line which Corel doesn't like...
Coreldraw retains the layer name. That's not a problem.
Problem is that if we have a macro in the Document and then save it. If we open it next CorelDRAW crashs.
© Corel Corporation. The content herein is in the form of a personal web log ("Blog") or forum posting. As such, the views expressed in this site are those of the participants and do not necessarily reflect the views of Corel Corporation, or its affiliates and their respective officers, directors, employees and agents. Terms and Conditions / User Guidelines.