VBA Borderdefinition.Edit(sketch) fails

VBA Borderdefinition.Edit(sketch) fails

M.Zirk
Advocate Advocate
173 Views
2 Replies
Message 1 of 3

VBA Borderdefinition.Edit(sketch) fails

M.Zirk
Advocate
Advocate

Hello,

 

in an IDW I have some border definitions.
I try to access a borderdefinition sketch, but receive an error.

Because I get the names of the borderdefinitions in the IDW, the initialisation before must be ok.

 

This method cuses the error:

Call oBorderDef.Edit(oDrawingSketch)

 

Sub ChangeBorderDefinition()

'On Error GoTo Errorhandler

Dim oDrawingDoc As DrawingDocument
Dim oDrawingSketch As DrawingSketch
Dim oBorderDef As BorderDefinition

Set oDrawingDoc = ThisApplication.ActiveDocument

For Each oBorderDef In oDrawingDoc.BorderDefinitions
    Debug.Print oBorderDef.Name
    Call oBorderDef.Edit(oDrawingSketch)
Next oBorderDef

Exit Sub

Errorhandler:
    Debug.Print Err.Description
    Debug.Print Err.Number
End Sub

 

Any ideas what is going wrong?

 

Manfred

0 Likes
Accepted solutions (1)
174 Views
2 Replies
Replies (2)
Message 2 of 3

mateusz_baczewski
Advocate
Advocate
Accepted solution

Hi,

 

I believe this happens because, when you iterate through all frames, you end up trying to edit the default frame—which isn’t editable. That’s why you’re seeing an error. Below is a snippet of code that lets you edit a frame.

 

Sub main
	
	Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
	Dim oBorders As BorderDefinitions = oDoc.BorderDefinitions
	Dim oBorder As BorderDefinition = oBorders.Item(2)
	
	Dim oSheet As Sheet = oDoc.ActiveSheet
	Dim oDrawSketch As DrawingSketch
	
	oBorder.Edit(oDrawSketch)
	
End Sub

 

If you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".

0 Likes
Message 3 of 3

M.Zirk
Advocate
Advocate

Hello  Mateusz,

thank you for your help.

 

Manfred

 

0 Likes