×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to create a macro to update swSumInfoCreateDate

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
 

RE: How to create a macro to update swSumInfoCreateDate

Creation dates are usually not accessible and not writeable.

Curious why one would need to do this?

RE: How to create a macro to update swSumInfoCreateDate

(OP)
TheTick,

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've had some luck changing file create dates by going into the bitses and bytses and changing it there.  That's risky hacksmanship, though.  You do this by opening the SW file in a text editor like Notepad or Wordpad.

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://esoxrepublic.com/blog/category/api/internal-id/

batHonesty may be the best policy, but insanity is a better defense.bat
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: How to create a macro to update swSumInfoCreateDate

(OP)
I'll check it out.  Does my code look like it would work or is the field just uneditable?  Thanks!

RE: How to create a macro to update swSumInfoCreateDate

If you can read the property and you can write to similar properties, it's probably not API accessible.

RE: How to create a macro to update swSumInfoCreateDate

(OP)
That could be because I can do a debug.print on the field and get a return.  The only other thing I can think of is that I'm trying to populate the field with an incorrect format for the date.  I used to do quite a bit of SQL and I remember dates and date formats can be fussy.  Do you know what format I should be providing the date for the swSumInfoCreateDate?  MM/DD/YYYY TIME,ETC....

Please advise.  Thanks!

RE: How to create a macro to update swSumInfoCreateDate

Sorry.  That last request just bounced right off the outer limits of my knowledge.

RE: How to create a macro to update swSumInfoCreateDate

(OP)
Thank all of you for all your help, I'm finding out from several spots that this field is read only.

RE: How to create a macro to update swSumInfoCreateDate

Do you really have customers snooping into create dates?  Oy!  Though you could always tell them that's when the template was created.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources