Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all, I am trying to convert a current rule to a save dialog from a folder dialog. I can't figure out how to pass the folder and filename from the dialog. Can someone help my tired brain? Here is my rule:
'Export DWG as PDF with options oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 'File Name Dim FileName As String If iProperties.Value("Project", "Revision Number") <> "" Then FileName = ThisDoc.FileName(False) & " Rev" & iProperties.Value("Project", "Revision Number") Else FileName = ThisDoc.FileName(False) End If 'File Path Dim FilePath As String = ThisDoc.Path 'Old: Dialog for choosing folder path 'New: Dialog for saving file Dim Dialog As New SaveFileDialog() 'Dialog.SelectedPath = FilePath 'Dialog.Description = "Click OK for Current Location" & vbLf & " or " & vbLf & " Select New File Location and Click OK" Dialog.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*" Dialog.DefaultExt = "pdf" Dialog.FilterIndex = 1 Dialog.InitialDirectory = FilePath Dialog.FileName = FileName 'If Dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then If Dialog.ShowDialog() = DialogResult.OK Then 'FilePath = Dialog.SelectedPath FileName = Dialog.FileName Else Exit Sub End If 'Chosen Path and Filename oDataMedium.FileName = FilePath & "\" & FileName & ".pdf" 'Write New File Try oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) ThisDoc.Launch(FilePath) Catch MessageBox.Show("PDF not created. Please save DWG and/or close any open PDFs.", "NO PDF FOR YOU!") End Try Exit Sub
Solved! Go to Solution.