So far, the code is fine, but you need to tell the file where to save, as well as an extension!
Replacing your original SaveAs code with the following line should give you a workable example.
oDoc.SaveAs("C:\MegaFolder\" & oNewFileName & ".ipt", False)
Depending on your use, you may also want to have a Case Statement that fills in the extension needed at the end, based on the type of document that is currently active.
The following is a modification to the entire code block that you posted on the other thread :
'check for blank iProperty
If iProperties.Value("Summary", "Title") = "" Then
'prompt user for info if iProperty is blank
oTitle = InputBox("Title info must be filled out before saving file!", _
"iLogic - Title", iProperties.Value("Summary", "Title"))
'check for empty input
'in case the user cancels out of the Input box
If oTitle = "" Then
Return 'end rule
Else
End If
'write user input to the iProperty
iProperties.Value("Summary", "Title") = oTitle
End If
'check for blank iProperty
If iProperties.Value("Project", "Part Number") = "" Then
'prompt user for info if iProperty is blank
oPartNumber = InputBox("Part Number must be filled out before saving file!", _
"iLogic - Part Number", iProperties.Value("Project", "Part Number"))
'check for empty input
'in case the user cancels out of the input box
If oPartNumber = "" Then
Return 'end rule
Else
End If
'write user input to the iProperty
iProperties.Value("Project", "Part Number") = oPartNumber
End If
'Set the Path the file will live at :
Dim oPathName As String
oPathName = "C:\MegaFolder\"
'Set value of currrent file name
oNewFileName = iProperties.Value("Summary", "Title") _
& " " & "(" & iProperties.Value("Project", "Part Number") & ")"
'Get this active Document Object
oDoc = ThisDoc.Document
'Find the Document Type
Dim oDocType As String
Select Case oDoc.DocumentType
Case kPartDocumentObject
oDocType = ".ipt"
Case kAssemblyDocumentObject
oDocType = ".iam"
Case kDrawingDocumentObject
oDocType = ".idw"
Case kPresentationDocumentObject
oDocType = ".ipn"
Case Else
MessageBox.Show("Unknown Document Type!", "Document Type Error")
Return
End Select
'Save the file 'True = Save As Copy 'False = Save As
If System.IO.File.Exists(oPathName & oNewFileName & oDocType) = True Then
oDoc.Save()
Else
oDoc.SaveAs(oPathName & oNewFileName & oDocType, False)
End If
'End of iLogic File Namer.iLogicVB Code
I know that there are more file extensions than that, but this is simply a little outline of some things to consider when messing with saving files.
The last thing that I would like to point out is that there are no checks being done to the text being input into the iProperty fields that eventually are being used to make up the file name of whatever it is you're saving. This could eventually lead to an error occurring simply due to a bad input on the user's part. If you feel like you need to compensate for that possibility, then you should do so!
I hope that this helps.
If my solution worked or helped you out, please don't forget to hit the kudos button 🙂iLogicCode Injector:
goo.gl/uTT1IB