Neither of those links really gave my any more information than I already had. Autodesk's documentation on GoExcel is very poor. I only found the FindColumn function by accident, no documentation on that anywhere. Using that I was able to put together something that will allow the excel file to be more dynamic. It is not exactly what I wanted, but it accomplishes what I need. I've attached the new ipt for anyone else who might need something similar and listed the code below.
Sub Main()
If MessageBox.Show("Ready to create files?", "Create Files", MessageBoxButtons.YesNo) = vbYes Then
' reset the variable
part_load = ""
'assign the name of the excel file if it is not assigned.
If Trim(excel_file_name) = "" Then
MessageBox.Show("An excel file has not been defined for this part.","File Name Does Not Exist",MessageBoxButtons.OK)
Else
'define the excel file to open
xlFile = ThisDoc.Path & "\" & excel_file_name & ".xlsx"
'check for existing file
If System.IO.File.Exists(xlFile) Then
Dim oProgBar As Inventor.ProgressBar
Dim iStepCount As Long = 0
Dim iStepMax As Long = 0
Dim xlTab As String = "Sheet1"
Dim i As Integer = 2
Dim PartsList As New ArrayList
' load the excel file
GoExcel.Open(xlFile, xlTab)
'find columns
PartNumberCol = GetExcelColumnName(GoExcel.FindColumn("Part Number"))
CreateCol = GetExcelColumnName(GoExcel.FindColumn("Create"))
' get count of all files to generate and create list of parts numbers
While GoExcel.CellValue(xlFile, xlTab, PartNumberCol & i) > ""
If GoExcel.CellValue(CreateCol & i) = "Y" Then
PartsList.Add(GoExcel.CellValue(PartNumberCol & i))
iStepMax += 1
End If
i = i + 1
End While
'start progress bar
oProgBar = ThisApplication.CreateProgressBar(False, iStepMax + 2, "Creating Files")
oProgBar.Message = "Preparing to create files..."
oProgBar.UpdateProgress
MessageBox.Show("Doing the needed work before the fake files are created.","Pre-Work",MessageBoxButtons.OK)
For Each pn In PartsList
GoExcel.FindRow(xlFile, xlTab, "Part Number", "=", pn)
iProperties.Value("Project", "Part Number") = GoExcel.CurrentRowValue("Part Number")
iProperties.Value("Project", "Description") = GoExcel.CurrentRowValue("Description")
width = GoExcel.CurrentRowValue("Width")
length = GoExcel.CurrentRowValue("Length")
depth = GoExcel.CurrentRowValue("Depth")
iStepCount += 1
oProgBar.Message = "Creating " + CStr(iStepCount) + " of " + CStr(iStepMax) + " files. " + iProperties.Value("Project", "Part Number")
oProgBar.UpdateProgress
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()
ThisDoc.Save
DoWork()
Next
GoExcel.Close()
'iLogicVb.Automation.RulesOnEventsEnabled = True
oProgBar.Message = "Files Created."
oProgBar.UpdateProgress
MessageBox.Show("All files created, but not really. Just pretending.","Done",MessageBoxButtons.OK)
oProgBar.Close
Else
MessageBox.Show("The excel file or drawing file does not exist in the folder. Make sure the files were created or are checked out of vault.", "File Exists")
'iLogicVb.RunExternalRule("open working folder")
End If
End If
End If
End Sub
Sub DoWork()
' Where all the work will be done once values from the excel file are loaded into the ipt
MessageBox.Show("Pretending to do work to create part " & iProperties.Value("Project", "Part Number") & ". Just click OK.","Do Work",MessageBoxButtons.OK)
End Sub
Function GetExcelColumnName(columnNumber As Integer) As String
Dim dividend As Integer = columnNumber
Dim columnName As String = String.Empty
Dim modulo As Integer
While dividend > 0
modulo = (dividend - 1) Mod 26
columnName = Convert.ToChar(65 + modulo).ToString() & columnName
dividend = CInt((dividend - modulo) / 26)
End While
Return columnName
End Function
Thanks for the suggestions from those who responded. It is appreciated.