Hi,
I'm completely new to VBA, so I really don't know anything about the code, and it seems like everywhere I look for help it's assumed that I should already know a lot about it. I'm trying to find a macro that will insert text into a certain spot on my drawing. I want to put it on a button so that when I click the button it inserts "REVISION - 12/5/12", or whatever the current date is, into my title block. Does anything like this exist?
Thanks
Hi jjkoz78,
Here's a basic step-by-step to do this with iLogic code:
http://inventortrenches.blogspot.com/2012/01/creating-basic-ilogic-rule-with-event.html
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
It looks like it would probably help (if I can get everything in place first). I'm using Inventor 2008 and don't have iLogic. I've tried to download it, but I have to link up my subscription to my user account on Autodesk's website, and it's telling me that my account has been closed or canceled or something like that. Isn't there just some simple VBA code out there somewhere that can do what I'm wanting? I can't believe it's this complicated.
Hi jjkoz78,
I do have a VBA sample that will do what you want also. I'll try to post it in a hour or so. Are you familiar with setting the code up to run?
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hi jjkoz78,
Here is the VBA code for the time and date, as well as an attached sample file. The sample file is an Inventor 2010 file, sorry that's as far back as I can go.
I found this on the Customization Forum some time ago (thanks to whom ever wrote it originally). This code is set up to write the system time and date to custom iProperties when the file is saved, so you need to have the text fields set up to look at the custom iProperties in the file ahead of time (such as in the titleblock or border).
I've had some issues with 64 bit systems and other VBA code, but I think this works okay. However, it's been a while since I've used it.
To place this in your Inventor drawing file, open the file and then Press ALT + F11 to open the VBA editor. Locate the file you want to add the code to in the project browser and then set the ThisDocument node for that file active and paste in the code as shown in the attached image.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Option Explicit Public Sub AutoSave() Call AddSysDateTime End Sub Public Sub AddSysDateTime() Dim oPropSet On Error Resume Next 'Check if the active document is a Drawing If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then 'Add a custom property "SysDate" with system date Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") 'As a workaround the property must be delete because it can not be changed oPropSet.Item("SysDate").Delete Call oPropSet.Add(Format(Date, "mm/dd/yyyy"), "SysDate") 'Add a custom property "SysTime" with system time Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") 'As a workaround the property must be delete because it can not be changed oPropSet.Item("SysTime").Delete Call oPropSet.Add(Format(Time, "h:mm:ss am/pm"), "SysTime") 'Still having some problems that the last property does not update correct Call RefreshProperties End If End Sub Private Sub RefreshProperties() Dim oPropSet Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") Call oPropSet.Add("", "MyDummy") oPropSet.Item("MyDummy").Delete End Sub