Create a customr property

Create a customr property

Anonymous
Not applicable
400 Views
7 Replies
Message 1 of 8

Create a customr property

Anonymous
Not applicable
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes
401 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
The following code works fine for me:

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("abc", "2nd Proj. No")

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5183974@discussion.autodesk.com...
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thank you, San.
what I tried to do here is:
1) create a new custom property and it's value
2) if the custom property is already exist, replace its value
This code seems to work for adding a brand new property
what happens if "2nd Proj. No" is already exist?? and I want to replace its
value with a texbox.text??

Thx
"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184000@discussion.autodesk.com...
The following code works fine for me:

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("abc", "2nd Proj. No")

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5183974@discussion.autodesk.com...
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes
Message 4 of 8

Anonymous
Not applicable
Something along the following lines should work:

On Error Resume Next

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Dim oProp As Property
Set oProp = oPropSet.Item("2nd Proj. No")

If oProp Is Nothing Then
Call oPropSet.Add("abc", "2nd Proj. No")
Else
oProp.Value = "abc"
End If

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5184014@discussion.autodesk.com...
Thank you, San.
what I tried to do here is:
1) create a new custom property and it's value
2) if the custom property is already exist, replace its value
This code seems to work for adding a brand new property
what happens if "2nd Proj. No" is already exist?? and I want to replace its
value with a texbox.text??

Thx
"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184000@discussion.autodesk.com...
The following code works fine for me:

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("abc", "2nd Proj. No")

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5183974@discussion.autodesk.com...
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes
Message 5 of 8

Anonymous
Not applicable
Is there a way to use .delete to delete the existing value and repplace with
a new value
Most of my files contain more than 10 custom properties and I dont want to
use if statement 10 times
Thanks, Chris

"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184029@discussion.autodesk.com...
Something along the following lines should work:

On Error Resume Next

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Dim oProp As Property
Set oProp = oPropSet.Item("2nd Proj. No")

If oProp Is Nothing Then
Call oPropSet.Add("abc", "2nd Proj. No")
Else
oProp.Value = "abc"
End If

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5184014@discussion.autodesk.com...
Thank you, San.
what I tried to do here is:
1) create a new custom property and it's value
2) if the custom property is already exist, replace its value
This code seems to work for adding a brand new property
what happens if "2nd Proj. No" is already exist?? and I want to replace its
value with a texbox.text??

Thx
"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184000@discussion.autodesk.com...
The following code works fine for me:

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("abc", "2nd Proj. No")

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5183974@discussion.autodesk.com...
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes
Message 6 of 8

Anonymous
Not applicable
San,
Why this code works, but the one I posted originally doesn't work? Are they
identical???
Thx, Chris

On Error Resume Next

'Check if the active document is a Drawing
If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then

Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("SysDate").Delete
Call oPropSet.Add(Format(Date, "mm/dd/yy"), "SysDate")



"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184029@discussion.autodesk.com...
Something along the following lines should work:

On Error Resume Next

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Dim oProp As Property
Set oProp = oPropSet.Item("2nd Proj. No")

If oProp Is Nothing Then
Call oPropSet.Add("abc", "2nd Proj. No")
Else
oProp.Value = "abc"
End If

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5184014@discussion.autodesk.com...
Thank you, San.
what I tried to do here is:
1) create a new custom property and it's value
2) if the custom property is already exist, replace its value
This code seems to work for adding a brand new property
what happens if "2nd Proj. No" is already exist?? and I want to replace its
value with a texbox.text??

Thx
"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184000@discussion.autodesk.com...
The following code works fine for me:

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("abc", "2nd Proj. No")

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5183974@discussion.autodesk.com...
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes
Message 7 of 8

Anonymous
Not applicable
It's because of the 'On Error Resume Next' statement. This was commented out
in your original code. With this statement, even if the .Delete method
fails, the code continues on.

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5185440@discussion.autodesk.com...
San,
Why this code works, but the one I posted originally doesn't work? Are they
identical???
Thx, Chris

On Error Resume Next

'Check if the active document is a Drawing
If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then

Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("SysDate").Delete
Call oPropSet.Add(Format(Date, "mm/dd/yy"), "SysDate")



"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184029@discussion.autodesk.com...
Something along the following lines should work:

On Error Resume Next

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Dim oProp As Property
Set oProp = oPropSet.Item("2nd Proj. No")

If oProp Is Nothing Then
Call oPropSet.Add("abc", "2nd Proj. No")
Else
oProp.Value = "abc"
End If

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5184014@discussion.autodesk.com...
Thank you, San.
what I tried to do here is:
1) create a new custom property and it's value
2) if the custom property is already exist, replace its value
This code seems to work for adding a brand new property
what happens if "2nd Proj. No" is already exist?? and I want to replace its
value with a texbox.text??

Thx
"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184000@discussion.autodesk.com...
The following code works fine for me:

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("abc", "2nd Proj. No")

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5183974@discussion.autodesk.com...
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes
Message 8 of 8

Anonymous
Not applicable
Hi San,
It's not about the "on error resume next"
When I run this code to a new file, SysDate and SysTime are added.
Then I run this code again, the existing SysDate and SysTime are deleted and
replaced by new values
I used this code to update the Date and Time on my drawings.
However, when I tried to replace SysDate and Systime with different custom
properties, this code fails
I guess SysDate and SysTime are used the system's values, while others have
their values from textbox's text? Not sure if I'm right???
Chris

"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5185442@discussion.autodesk.com...
It's because of the 'On Error Resume Next' statement. This was commented out
in your original code. With this statement, even if the .Delete method
fails, the code continues on.

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5185440@discussion.autodesk.com...
San,
Why this code works, but the one I posted originally doesn't work? Are they
identical???
Thx, Chris

On Error Resume Next

'Check if the active document is a Drawing
If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then

Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("SysDate").Delete
Call oPropSet.Add(Format(Date, "mm/dd/yy"), "SysDate")



"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184029@discussion.autodesk.com...
Something along the following lines should work:

On Error Resume Next

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Dim oProp As Property
Set oProp = oPropSet.Item("2nd Proj. No")

If oProp Is Nothing Then
Call oPropSet.Add("abc", "2nd Proj. No")
Else
oProp.Value = "abc"
End If

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5184014@discussion.autodesk.com...
Thank you, San.
what I tried to do here is:
1) create a new custom property and it's value
2) if the custom property is already exist, replace its value
This code seems to work for adding a brand new property
what happens if "2nd Proj. No" is already exist?? and I want to replace its
value with a texbox.text??

Thx
"Sanjay Ramaswamy (Autodesk)" wrote in
message news:5184000@discussion.autodesk.com...
The following code works fine for me:

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("abc", "2nd Proj. No")

Sanjay-

"Chris (IV11 Pro. SPxx)" wrote in message
news:5183974@discussion.autodesk.com...
can someone pls tell me why I got erro when I tried to add a custom
property?
Thx

Private Sub cmdUpdate_Click()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'On Error Resume Next

Dim oPropSet As PropertySet
Set oPropSet =
oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

oPropSet.Item("2nd Proj. No").Delete
Call oPropSet.Add(txt2ndProjNum.Text, "2nd Proj. No")

oDoc.Update
End Sub

--
IV11 Pro. spxx
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 8.1.7.2
0 Likes