How to create a macro to update swSumInfoCreateDate
How to create a macro to update swSumInfoCreateDate
(OP)
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






RE: How to create a macro to update swSumInfoCreateDate
Curious why one would need to do this?
RE: How to create a macro to update swSumInfoCreateDate
Thanks for the reply. The reason is that we do quite a bit of design copying with pack and go and when we do that the creation date of the original file comes with and we would like to update that to when we did the pack and go. Thanks! Any ideas?
RE: How to create a macro to update swSumInfoCreateDate
I learned this when I was attempting to play god w/ SW files' internal IDs. I even had a small bit of success, and was able to fool SW into thinking one file was a clone of another when it was not.
http
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: How to create a macro to update swSumInfoCreateDate
RE: How to create a macro to update swSumInfoCreateDate
RE: How to create a macro to update swSumInfoCreateDate
Please advise. Thanks!
RE: How to create a macro to update swSumInfoCreateDate
RE: How to create a macro to update swSumInfoCreateDate
http://
swSumInforCreateDate is in a group referred to as read only.
You might be able to use System.FileInfo objects in VBNet or C# to set the creation time, but I expect that would need to be done without having the file open.
Eric
RE: How to create a macro to update swSumInfoCreateDate
RE: How to create a macro to update swSumInfoCreateDate