kreker
Mechanical
- Nov 4, 2004
- 13
I'm trying to create a macro to update the swSumInfoCreateDate field on an open file to today's date. I can get today's date with "Date$" and I can assign a string date to a variable but I cannot get the date into the swSumInfoCreateDate field. Here is my code. Please help. Thanks!!
Option Explicit
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Dim swApp As SldWorks.SldWorks
Dim swmodel As SldWorks.ModelDoc2
Sub main()
On Error Resume Next
Dim UserName As String
UserName = Space(40)
Dim DateCreated As String
'DateCreated = Date$
DateCreated = "5/9/2010 2:19:50 PM"
UserName = "CAS"
Set swApp = Application.SldWorks
Set swmodel = swApp.ActiveDoc
swmodel.SummaryInfo(swSumInfoAuthor) = UserName
swmodel.SummaryInfo(swSumInfoCreateDate) = DateCreated
Debug.Print DateCreated
Debug.Print swmodel.SummaryInfo(swSumInfoCreateDate)
Debug.Print UserName
If Not Err.Number = 0 Then MsgBox "An unexpected error occured.", vbOKOnly + vbCritical, "Setting Author summary fails."
End Sub
Option Explicit
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Dim swApp As SldWorks.SldWorks
Dim swmodel As SldWorks.ModelDoc2
Sub main()
On Error Resume Next
Dim UserName As String
UserName = Space(40)
Dim DateCreated As String
'DateCreated = Date$
DateCreated = "5/9/2010 2:19:50 PM"
UserName = "CAS"
Set swApp = Application.SldWorks
Set swmodel = swApp.ActiveDoc
swmodel.SummaryInfo(swSumInfoAuthor) = UserName
swmodel.SummaryInfo(swSumInfoCreateDate) = DateCreated
Debug.Print DateCreated
Debug.Print swmodel.SummaryInfo(swSumInfoCreateDate)
Debug.Print UserName
If Not Err.Number = 0 Then MsgBox "An unexpected error occured.", vbOKOnly + vbCritical, "Setting Author summary fails."
End Sub