Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Properties extracting with VBA

Status
Not open for further replies.

mdrummond

Industrial
Feb 21, 2008
37
Hello,

I want to extract my file properties to a spread sheet. I found some code below, but I believe it needs some tweeking. I am no programmer, that's for sure. Can anyone take a crack at this thing, and make it work as a macro for excel?

SYMPTOM/PROBLEM
---------------
How do you extract the file properties for a Solid Edge file using VB
Automation API?


SOLUTION/WORKAROUND
-------------------
All the file properties that are listed under the "File/Properties" dialog can
be extracted by a VB propgram or a VBA macro in a spreadsheet. Just make sure
that your project has a reference to the type library called "Solid Edge File
Properties". The sample code below can be modified to suit your needs:

Sub GetFileProps()
Dim objPropSets As PropertySets
Dim objProps As Properties
Dim objProp As Property


Set objPropSets = CreateObject("SolidEdge.FileProperties")
Call objPropSets.Open("c:\temp\Part1.par")

'For Each objProps In objPropSets
' For Each objProp In objProps
' Debug.Print objProps.Name, ": ", objProp.Name, " = ", objProp.Value
' Next
'Next

Set objProps = objPropSets.Item("ProjectInformation")
For Each objProp In objProps
Debug.Print objProp.Name, " = ", objProp.Value
Next

Set objProps = objPropSets.Item("SummaryInformation")
For Each objProp In objProps
Debug.Print objProp.Name, " = ", objProp.Value
Next


Set objProps = objPropSets.Item("MechanicalModeling")
For Each objProp In objProps
Debug.Print objProp.Name, " = ", objProp.Value
Next

Set objProps = objPropSets.Item("Custom")
For Each objProp In objProps
Debug.Print objProp.Name, " = ", objProp.Value
Next

End
End Sub
 
Replies continue below

Recommended for you

There used to be pdf on customizing solid edge on the UGS web site but I can't locate it.
It was V15 but there was a section on how to get file properties, which hasn't really changed.
I have it somehere and will post later when I find it.

bc.
2.4GHz Core2 Quad, 4GB RAM,
Quadro FX4600.
 
Sounds good. I could really use it.

Thanks.
 
Page 161 shows how to get all file properties.
If you get the properties one section at a time you need to be careful because some do not exist in certain file types. I think it's the MechanicalModeling property set that does not exist in a draft file.
I had this problem when I was learning and had to check the file type so that I didn't get an error.

bc.
2.4GHz Core2 Quad, 4GB RAM,
Quadro FX4600.
 
Cool. I'll keep that in mind. My problem is that I 100% to vb programing or programming of any kind. Don't suppose anyone out there has already got an excel macro done up for this,eh?
 
I think I have a program that gets all models linked to a draft file and saves the result in a text file.
This would show you how to create a new file and add information to it.
If you think it may be of help I'll have a look and post it later.
The code is probably not the best but it does work, and like you I'm self-taught and not an expert, so that's my excuse.

bc.
2.4GHz Core2 Quad, 4GB RAM,
Quadro FX4600.
 
Sweet, I'll take it. Any example/resource I can get will help, and I need alot of help. On the Microsoft website there are a whack of tutorials for VB. I've down loaded the express addition and have started trying to learn. Hopefully I start getting the hand of it soon.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor