Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, I have a piece of code that shows a dialogue box to select a folder and enter a file name. My problem is that it uses the "On error resume next" line of code to function correctly.
I'd like to remove this line and still trap the error if someone cancels out of the save or does not enter a file name.
'define the active document oDoc = ThisDoc.Document 'create a file dialog box Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) 'set the directory to open the dialog at oFileDlg.InitialDirectory = ThisDoc.WorkspacePath() 'set the file name string to use in the input box oFileDlg.FileName = iProperties.Value("Project", "Part Number") 'work with an error created when cancelling the save oFileDlg.CancelError = True On Error Resume Next 'specify the file dialog as a save dialog oFileDlg.ShowSave() 'catch an empty string in the input If Err.Number <> 0 Then Return ElseIf oFileDlg.FileName <> "" Then f = oFileDlg.FileName 'save the file oDoc.SaveAs(f, False) End If
Solved! Go to Solution.