Hi,
I have this macro, whenever I have 2 documents it works fine, but if have more documents the Corel stops responding.
Can anyone help me?
Sub tentativa3() Dim d As Document, d1 As Document Dim x As Integer Dim n As String, n1() As String, n2 As String x = 0 For Each d In Documents If x = 0 Then d.Activate x = 1 End If Next d For Each d In Documents MsgBox (d.Name) If d.Name Like "*-TRIMS*" Then d.Close ActiveWindow.Refresh End If If d.Name Like "*-FABRIC*" Then aux = 0 d.Activate n = d.Name n1 = (Split(n, "-")) n2 = n1(0) & "-" & n1(1) MsgBox (n2) MsgBox (d.Name) MsgBox (d.Active) For Each d1 In Documents If d1.Name Like n2 & "-TRIMS*" Then d1.Activate MsgBox (d1.Name) MsgBox (d1.Active) End If Next d1 d.Close ActiveWindow.Refresh End If Next dEnd Sub
This macro works for me with two, three, and even four open files. Maybe you have forbidden characters in the names of open files?Taras
As soon as I added the file named =3518735-468-TRIMS.HPGL= (you sent it last week) to the list of open files, Coreldraw crashed twice. I think it's because the macro closed the file, but the name remained in the list of documents, and during the next iteration the program refers to a non-existent object.
I wrote to you on e-mail