02-12-2020
11:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-12-2020
11:44 PM
Hello @mraymond7REU2,
regarding your first post. Try this code snippet and see if it works for you.
You just have to put your paths back.
Sub Main()
'declare variable for inventory master excel file
excel_file = "C:\Users\Aleksandar.Kr\Desktop\Kurze Übung.xlsx"
'open excel file
Dim oExcel = CreateObject("Excel.Application")
Dim oWorkbook = oExcel.Workbooks.Open(excel_file)
oExcel.Application.Visible = True
'Create folder variable and Select folder with drawings in it
Dim Folder As New IO.DirectoryInfo("C:\Users\Aleksandar.Kr\Desktop\test123\")
'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 (oWorkbook.Sheets("Sheet1").Cells(i, 1).Value = "") Then
'this command will run on each document in the folder variable
oWorkbook.Sheets("Sheet1").Cells(i, 1).Value = iProperties.Value("Project", "Part Number")
oWorkbook.Sheets("Sheet1").Cells(i, 2).Value = iProperties.Value("Project", "Revision Number")
oWorkbook.Sheets("Sheet1").Cells(i, 3).Value = iProperties.Value("Project", "Description")
Exit For
Else
i = + 1
End If
Next
oDoc.Close
Next
oWorkbook.Save
oWorkbook.Close
End Sub
regards,
Aleks