- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need help with this code. The goal is to export all the sheets in a idw file to seperate idws with the sheet name as the file name. The code works. All the sheets are saved in a new folder created called " Sheets". All new idw files are named with the sheet name.
Issue: The new idws dont open.
From my understanding the way the code needs to work is, add a number on the sheet names to be a counter. Then deleted all sheets except one and save as new idw file. Then go to the next counter number and repeat.
'------start of iLogic-------
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
'Define the drawing
Dim oDrawing As DrawingDocument
oDrawing = ThisDoc.Document
Dim oSheet As Sheet
Dim lPos As Long
Dim rPos As Long
Dim sLen As Long
Dim sSheetName As String
Dim iSheetNumber As Integer
'step through each drawing sheet
For Each oSheet In oDrawing.Sheets
'find the seperator in the sheet name:number
lPos = InStr(oSheet.Name, ":")
'find the number of characters in the sheet name
sLen = Len(oSheet.Name)
'find the sheet name
sSheetName = Left(oSheet.Name, lPos -1)
'find the sheet number
iSheetNumber = Right(oSheet.Name, sLen -lPos)
'get SHEET target folder path
oFolder = Left(oPath, InStrRev(oPath, "\")) & "Sheets"
'Check for the PDF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'Set the SHEET target file name
oDataMedium.FileName = oFolder & "\" & oFileName & " " & sSheetName & ".idw"
'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Next
'------end of iLogic-------
Solved! Go to Solution.