Macro to copy "Description" custom property to clipboard.

I need to input the description manually into our PDM system until we get some scripting written. Does anyone know how I can copy the "Description" custom property of a model into the windows clipboard? This would allow me to 1. Open a model 2. Run the macro 3. Paste the description in the description field in PDM card.

We use Smarteam for PDM, but we are waiting on the next upgrade which should have new scripting to transfer the description automatically.

Reply to
SW Monkey
Loading thread data ...

Just off the top of my head try this. In Windoze Explorer right click on the file, go to properties, go to custom tab, click on "description" in properties box, right click in value and select all, copy, then paste. Yes I now it's a lot of clicking but at least you don't have to open every file. Hope it helps.

Reply to
Matthew A. Bush

Quick search of the help I came up with this.

Create a user form with a text box add code to the user form so it will extract the description and put it in the text box say it is Textbox1 add these lines

TextBox1.SelStart = 0 TextBox1.SelLength = TextBox1.TextLength TextBox1.Copy End

Corey

Reply to
Corey Scheich

Reply to
SW Monkey

Try Model.CustomInfo2("", "Description")

This will get the Description property for the document. If you want a specific configuration, just pass it instead of the empty string.

Reply to
Evan T. Basalik

I tried that, but I keep getting an error that something is missing.

Anyone pretty good with VB that can whip up the code pretty quick? It seems like something very simple to do, but I cant figure it out :)

Thanks :)

Reply to
SW Monkey

Here is some code I had lying around it was for a different purpose but it is similar

Private Sub UserForm_Initialize() 'code created by Corey Scheich Dim ThisSheet As SldWorks.Sheet Dim ThisView As SldWorks.View Dim ThisViewName As String Dim ModelName As String Dim ThisModel As SldWorks.ModelDoc2 Dim Description As String Dim CustomInfoNms() As String Dim Count As Long Dim swDrw As SldWorks.DrawingDoc Dim swApp As SldWorks.SldWorks

Set swApp = Application.SldWorks Set swDrw = swApp.ActiveDoc

Set ThisSheet = swDrw.GetCurrentSheet ThisViewName = ThisSheet.CustomPropertyView Set ThisView = swDrw.GetFirstView

Do While Not ThisView Is Nothing If ThisViewName = ThisView.Name Then Exit Do End If Set ThisView = ThisView.GetNextView Loop

If ThisView Is Nothing Then Set ThisView = swDrw.GetFirstView ModelName = ThisView.GetReferencedModelName While ModelName = "" And Not ThisView Is Nothing Set ThisView = ThisView.GetNextView If ThisView Is Nothing Then Exit Sub ModelName = ThisView.GetReferencedModelName Wend If ThisView Is Nothing Then Exit Sub End If Set ThisModel = swApp.GetOpenDocumentByName(ModelName)

CustomInfoNms = ThisModel.GetCustomInfoNames2("") Count = 0 Description = "" For Count = 0 To UBound(CustomInfoNms) If VBA.LCase(CustomInfoNms(Count)) = "description" Then Description = ThisModel.GetCustomInfoValue("", CustomInfoNms(Count)) Exit For End If Next

UserForm1.TextBox1 = Description TextBox1.SelStart = 0 TextBox1.SelLength = TextBox1.TextLength TextBox1.Copy End End Sub

I just tested this and it works You have to create a form named Userform1 and a text box named TextBox1

The first user form and textbox you create should be named this by default

then in the code for the userform add the code above you will never see the form when the code runs

Regards,

Corey Scheich

Reply to
Corey Scheich

Oh yeah that code is meant to be used from a drawing. You will have to strip it to use it from the model. Or edit it to check wether it is in a drawing or a model when you run it.

Corey

Reply to
Corey Scheich

Reply to
SW Monkey

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.