Splitting multi-sheet documentation into single idw files

Splitting multi-sheet documentation into single idw files

idealogicERZYZ
Advocate Advocate
208 Views
2 Replies
Message 1 of 3

Splitting multi-sheet documentation into single idw files

idealogicERZYZ
Advocate
Advocate

 

Hello,
I found a code on the forum that allows me to split a multi-sheet file into single idw files. The code works if there is only one view in the sheet, then the code saves the file to the name of the source file of this view, but if there are more views, the code saves to the name of the default template file. Please help me get the appropriate name from the base view from a sheet with n views.

 

 

 Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    'Set oDrawDoc = ThisApplication.ActiveDocument
    
    Dim str1 As String
    str1 = oDrawDoc.FullFileName
    Dim s As Sheet
    
    For Each s In oDrawDoc.Sheets
        s.Activate
        Dim oDrawDoc1 As DrawingDocument
        
        'Set oDrawDoc1 = ThisApplication.Documents.Add(kDrawingDocumentObject)
	oDrawDoc1 = ThisApplication.Documents.Add(kDrawingDocumentObject)       
		        
        Call s.CopyTo(oDrawDoc1)
        oDrawDoc1.Sheets.Item(1).Delete
        Dim Str As String
        Str = s.DrawingViews.Item(1).ReferencedDocumentDescriptor.FullDocumentName
        Str = Right(Str, Len(Str) - InStrRev(Str, "\"))
        Str = Left(Str, Len(Str) - 4)
        Dim fname As String
    		
		 fname = Replace(str1, ".idw", "_" & Replace(s.Name, ":", "_") & "_" & Str & ".idw")
	  Next

 

 

 

idealogicERZYZ_3-1701690173014.png

 

Single view sheet

 

idealogicERZYZ_0-1701690312682.png

 

 

 

Sheet with multiple views

 

idealogicERZYZ_2-1701690140544.png

 

thx E

 

0 Likes
209 Views
2 Replies
Replies (2)
Message 2 of 3

cidhelp
Advocate
Advocate

Hi @idealogicERZYZ ,

 

in your iLogic-Code the filename is created as string fname, but the file is not saved with this filename.

Add

oDrawDoc1.SaveAs(fname, False)

before the last Next-line, and each file will be saved with this name.

0 Likes
Message 3 of 3

idealogicERZYZ
Advocate
Advocate

Yes, that's right, I don't really need the fname variable, I need to save to a file whose name is the file name in the base view.

In this code the fanme variable takes the sheet name and the source file name and I only need the source file name ipt or iam

 

 

 

 

0 Likes