automated save-as to create vsd and pdf with same file name

Started by jayd4wg, June 06, 2018, 08:07:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jayd4wg

I'm callling uncle on this.  I've been trying to accomplish a simple task using VBA that is honestly a feature that I think should be built in already.

I'm constantly creating customer facing network drawings and revisions of these same drawings at a later time, they become archived documents over time showing the progression of changes to a customer network.

So obviously, I need the functionality of saving the vsd format, but because our provisioning team is primarily apple based (we are windows), and for sending the drawings to our customers, we save them as a PDF as well. 

Ideally what I'd like to have happen is to create a button to fire a macro that does the following:
call the fileSaveAs dialog just like we'd normally do by hitting file>save as - this is the mechanism that allows us to create the modified file name (basically changing the date at the end of the file name)
then, upon save, automatically export the same drawing as a pdf. 

A number of problems have presented themselves.  Using a macro-enabled template, Visio creates a new document "Document1"  and immediately after saving as vsd format...it's no longer macro enabled and drops out of the macro to complete the gathering ThisDocument.Path and ThisDocument.Name, replacing the ".vsd" with ".pdf" and using the ExportAsFixedFormat visFixedFormatPDF

Searching the wonderwebs has yielded very little.  I'm guessing that i'm not alone in wanting this functionality but for the love of all that's holy, this has been a 5 headed dragon of a short bit of code. 

Anyone have any ideas?

Ralli

Hi,

I was running into the same problem.
Unfortunately, I haven't found a built-in routine that starts the "save as" dialog.
For this reason I have found a routine on the net that emulates the functions "Save as Visio document with macros" and "Save as PDF" as follows:


  • User selects a path via dialogbox
Private Declare Function SHGetPathFromIDList Lib _
   "shell32.dll" (ByVal pIDL As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib _
   "shell32.dll" (lpBrowseInfo As BROWSEINFO) As Long
....



  • Generate a file name
  • Save as vsdm
ThisDocument.SaveAs path&filename


  • Save as pdf
ActiveDocument.ExportAsFixedFormat visFixedFormatPDF, path&filename, visDocExIntentPrint, visPrintCurrentPage

jayd4wg

I like it.  I'll tinker with this a little today and see if i can make it work.  THANK YOU!