Private Sub btnAddFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddFile.Click Dim doc As Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim acDoc As Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim strDWGName As String Dim strFolderPath As String Dim strListboxName As String = Nothing Try If TreeView1.SelectedNode Is Nothing Then ' nothing sleected for folder MsgBox("Select a folder first (node in the tree)") Exit Sub End If Dim diaSave As New ProjectsSaveCurrentDWG() ' Make new empty object of dialog box strFolderPath = TreeView1.SelectedNode.Tag.ToString 'If it's needed add a "\" to the path If Not strFolderPath.Substring(strFolderPath.Length - 1) = "\" Then strFolderPath = strFolderPath + "\" End If diaSave.tboFolder.Text = strFolderPath diaSave.tboName.Text = System.IO.Path.GetFileNameWithoutExtension(acDoc.Name) If diaSave.ShowDialog() = DialogResult.OK Then 'Check if valid filename If diaSave.tboName.Text = "" Then MsgBox("You failed to enter a file name!") Exit Sub End If If FilenameIsOK(strFolderPath + diaSave.tboName.Text) Then 'Valid filename entered Dim obj As Object = ApplicationServices.Application.GetSystemVariable("DWGTITLED") strDWGName = strFolderPath + diaSave.tboName.Text strListboxName = diaSave.tboName.Text 'Used to add file to listbox '' Save the active drawing acDoc.Database.SaveAs(strDWGName, True, DwgVersion.Current, _ acDoc.Database.SecurityParameters) Else MsgBox(diaSave.tboName.Text + vbCrLf + " You entered an invalid file name!") Exit Sub End If End If 'Add to listbox ListBox1.Items.Add(strListboxName + ".dwg") Catch ex As System.Exception ed.WriteMessage(vbLf & "Exception during btnAddFile_Click: {0}", ex.Message) End Try End Sub ' Saves current DWG into current Tree Node directory