Hi guys,
over the past months we've encountered several strange behaviours in our Designer macros.
Those macros were all running fine in X6, but are now going more and more wild with every slight change to our infrastructure.
Latest and most annoying example is the OpenDocument method.
While our original macro saved the current document, closed it and opened our template again - this has not been working anymore after upgrading to X7:
Original code:
answer = MsgBox("Dokument schliessen und Vorlage öffnen?", vbQuestion + vbYesNo, "Nachfrage") If answer = 6 Then ActiveDocument.Dirty = False ActiveDocument.Close Application.OpenDocument ("D:\ST4_Grafiken\00_Vorlage\Vorlage.des") End If Unload saveDocument_Form
Interesting enough, this actually works if there is already another document opened.
To work around this, we've set up a small macro that does the opening of the template by a single button press:
Public Sub openVorlage() Application.OpenDocument ("D:\ST4_Grafiken\00_Vorlage\Vorlage.des") End Sub
This works for the combination X7 and Windows 7 - it does not for an installation under Windows 10. We're getting some obscure time out error when executing it.
Even more strange is the fact, that the original macro (the first snippet I posted) does not return this error. Instead it keeps the form it's called in open and does not execute the Unload command, while still not loading the template.
Any ideas?
-Alex
My first thought is since x7 now incorporates .NET you may be running into some coding issues.
For example, I am assuming you are supplying the complete code for our review as is customary. That means, to me, your variables are not declared. The variable answer, for example. I know this may sound trivial, but Corel acts very strangely about such things. Understanding this behavior, while I agree it may be undesirable, has led me to code better and more efficiently. The use of option explicit above any function or sub program which requires me to declare any variable used so that I do not accidentally create a new variable because I misspelled an existing one. I will try your code and get back to you but I certainly would start with variable declaration.