Hi all, I'm trying to write a macro to create a file log that records every change of active document.
I would like to write to a file a list of date / time / filename of the active document (part/assembly/drawing).
Therefore the macro should trigger a function that write to a file every time the active document chages.
Following the suggestions I found on the following link
I created the following macro:
Dim MyClass As New Notification_Class
Class Module: (Notification_Class)
Dim WithEvents swApp As SldWorks.SldWorks
Dim MyModel As SldWorks.ModelDoc2
Public Sub MonitorSolidWorks()
Set swApp = Application.SldWorks
Private Function swApp_ActiveDocChangeNotify() As Long
Dim Time As Date
Dim FileName As String
' Get active document
Set MyModel = swApp.ActiveDoc
' Open output file for writing document change log file
Open "c:\temp\swActiveDocLog.txt" For Output As #1
FileName = MyModel.GetPathName
Time = DateTime.Date & DateTime.Time
' Write to output file
Write #1, Time & "Active doc: " & FileName
' Close the output file
I get no results. It seems the function will not run when the active document changes.
Thanks in advance for your help.