Message 1 of 16
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I am trying to export the iproperties of all the drawings in our drawing folder to an excel sheet, is there an existing way to do this? I have put together an ilogic script from a bunch of other posts but I cant get it to work, I frequently get this error, Unspecified error (Exception from HRESULT: 0X80004005 (E_FAIL)). Any help would be much appreciated.
Sub Main() 'declare variable for inventory master excel file excel_file = "C:\Users\mraymond\Documents\inventory-master.xlsx" 'open excel file GoExcel.Open(excel_file, "Sheet1") 'Create folder variable and Select folder with drawings in it Dim Folder As New IO.DirectoryInfo("C:\Users\mraymond\Documents\R-Drive Copy\test\") 'Create file list variable that will contain list of files in string format Dim FileList As New List(Of String) 'for loop that will loop through each file found in folder variable and add to file list For Each File As IO.FileInfo In Folder.GetFiles("*.idw",IO.SearchOption.AllDirectories) If File.FullName.Contains("OldVersions") = False Then FileList.Add(File.FullName) End If Next 'display count of files found in folder MsgBox(FileList.Count & " Files were found!") 'create variable for document Dim oDoc As Document 'for loop that goes through file on the file list variable For Each DocName As String In FileList oDoc = ThisApplication.Documents.Open(DocName, True) 'for loop to find the first empty row in the inventory master excel file Dim i As Integer For i = 2 To 20000 'find first empty cell in column A If (GoExcel.CellValue("A" & i) = "") Then 'this command will run on each document in the folder variable GoExcel.CellValue(excel_file, "Sheet1", "A" & i) = iProperties.Value("Project", "Part Number") GoExcel.CellValue(excel_file, "Sheet1", "B" & i) = iProperties.Value("Project", "Revision Number") GoExcel.CellValue(excel_file, "Sheet1", "C" & i) = iProperties.Value("Project", "Description") Exit For Else i = + 1 End If Next oDoc.Close Next GoExcel.Save GoExcel.Close End Sub
Solved! Go to Solution.