I'm at a dead end with connecting our C# application to 2018, as it was in X7. Hoping someone in this awesome community can point me in the right direction.
We use an "Automate" layer as a trigger to grab order information for our macros and read embedded data from a shape on the page. This is not working in my initial tests on 2018. The Macros work just fine manually, but not in our Automation process which is fed by an external C# application feeding the appropriate order information.
Stored in ThisDocument within each template:
Option Explicit
'Trigger build if layer created named "Automate"Private Sub Document_LayerCreate(ByVal Layer As Layer) If Layer.Name = "Automate" Then ActivePage.Layers("Automate").Delete
Dim s As Shape Set s = ActivePage.FindShape("OrderData")
If s Is Nothing Then MsgBox "OrderData not found." Exit Sub End If
Dim size As Double Dim spec As Double Dim size As Double Dim word1 As String Dim size As Double Dim word2 As String Dim word3 As String Dim word4 As String Dim names() As String
size = s.Properties("order", 1) spec = s.Properties("order", 2) word1 = UCase(s.Properties("order", 3)) word2 = UCase(s.Properties("order", 4)) word3 = UCase(s.Properties("order", 5)) word4 = UCase(s.Properties("order", 6)) names = s.Properties("order", 7)
s.Delete
Build size, spec, word1, word2, word3, word4, names End IfEnd Sub
The "Automate" layer is being created, as is the "OrderData" object. The process stops there. Debugging hasn't caught anything for me.
Example of the "OrderData" Invisible Object that contains the META data for the order.
This is the section of code for the C# program that creates the "Automate" layer and the "OrderData" META info.
I'm a bit baffled as the "Automate" layer as well as the OrderData shape is being created, so the communication to 2018 appears to be working as it did in X7.
If anyone has any suggestions or ideas I would be extremely grateful!
Thanks, Matt
I miscommunicated information about my debugging.
When adding a break at " If Layer.Name = "Automate" Then" it never hits that part of the code, so it appears to be ignoring the code in ThisDocument, altogether?
maybe externally created layers do not trigger layer events,
is a way to call your macros by their external application,
this code works fine to monitor layer events in 2018
https://github.com/bonus630/ActiveLayerControl/blob/master/ActiveLayerControl/LayerControlController.cs
you need subscribe the layer event whenever you open or create a document
I appreciate the suggestions. It appears that we aren't the only ones having issues calling from Document. We are in touch with Corel contact, will let you know what I hear back.