Message 1 of 3

Not applicable
06-23-2021
09:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning,
I have a problem with this code,
I need to change the border of a drawing with a border that I have on my desktop, but it doesn't works
I will be grateful with the help
Sub Main() Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oBorder As Border = oSheet.Border DeleteBorders InsertBorder End Sub Sub DeleteBorders() Dim oDrawDoc1 As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet1 As Sheet = oDrawDoc1.ActiveSheet For Each oSheet1 In ThisApplication.ActiveDocument.Sheets If Not oSheet1.Border Is Nothing Then oSheet1.Border.Delete End If Next End Sub Sub InsertBorder() Dim oDrawDoc3 As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet3 As Sheet = oDrawDoc3.ActiveSheet Dim borderDef As BorderDefinition strBorderRequired = True Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument ThisDrawing.ResourceFileName = "C:\Users\Desktop\Codigos\Templates\Parts.idw" Dim SourceFile = ThisDrawing.ResourceFileName Dim strSourceIDW As DrawingDocument strSourceIDW = ThisApplication.Documents.Open(SourceFile, False) For Each borderDef In strSourceIDW.BorderDefinitions If (StrComp(borderDef.Name, vbTextCompare) = 0) Then CopyFrom = borderDef.CopyTo(strDrawDoc, True) End If Next strSourceIDW.Close() Dim oNewBorderDef As BorderDefinition oNewBorderDef = oDrawDoc3.BorderDefinitions.Item(borderDef.Name) For Each oSheet3 In oDrawDoc3.Sheets oSheet3.AddBorder(oNewBorderDef) Next MessageBox.Show("The border was changed", "Title") End Sub
Solved! Go to Solution.