Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've written this code to automatically generate parts using a spreadsheet and a parameterized model. So far it has been working well. The only problem is that parts are saved to the same folder as the model. I would like to be able to select a save folder for the new parts, similar to how the .xlxs is selected at the beginning. A small handful of people will be using this for different purposes, so unfortunately I cant send everything to a set folder.
I'm new to iLogic and honestly, coding in general (This script is a Frankenstein's monster of whatever I could find online, I'm not even completely sure what everything means...) Any help would be greatly appreciated!
Dim fd As OpenFileDialog = New OpenFileDialog()
Dim strFileName As String
fd.Title = "Select File For Data"
fd.Filter = "All Files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then strFileName = fd.FileName
GoExcel.Open(strFileName,"Acrylic Cutting Schedule")
If strFileName = fd.FileName
MessageBox.Show("Excel data successfully imported!")
Else
MessageBox.Show("Excel data import FAILED. Check File.")
End If
Dim sFilePath As String= ThisDoc.Path & "\"
Dim sNewName As String
Dim doc As Document = ThisDoc.Document
Dim xDoc As Document
For i = 14 To qty
sNewName = GoExcel.CellValue("B" & i)
doc.SaveAs(sFilePath & sNewName & ".ipt", True)
xDoc = ThisApplication.Documents.Open(sFilePath & sNewName & ".ipt")
Dim oPars As UserParameters = xDoc.ComponentDefinition.Parameters.UserParameters
oPars.Item("width").Expression = "isolate(" & GoExcel.CellValue("D" & i) & ";in;in)"
oPars.Item("height").Expression = "isolate(" & GoExcel.CellValue("I" & i) & ";in;in)"
oPars.Item("thk").Expression = "isolate(" & GoExcel.CellValue("C" & i) & ";in;in)"
xDoc.Save
xDoc.Close(True)
Next i
GoExcel.Close
iLogicVb.UpdateWhenDone = True
Solved! Go to Solution.