Hello,
I have a visio template in which I have a reference nr field (Custom formula =DOCLASTEDIT() in format {{MyyHHmm}})
Now I want to create a vba code that will save the file with a chosen file name and the reference nr.
so the output would be something like test8181545.vcdx
Can anyone help me with this. Or is there a better way to do this.
See this for programmatically saving a file: https://docs.microsoft.com/en-us/visualstudio/vsto/how-to-programmatically-save-visio-documents (https://docs.microsoft.com/en-us/visualstudio/vsto/how-to-programmatically-save-visio-documents)
As an observation, I would change the timestamp order to year,month, hour, minutes. The Windows naming takes a left right, alpha/numeric precedence. Thus, your files would be naturally sorted by name, then year, month, etc. Just a suggestion.
Hope the link helps.
Wapperdude
Quote from: wapperdude on August 10, 2018, 01:32:40 AM
See this for programmatically saving a file: https://docs.microsoft.com/en-us/visualstudio/vsto/how-to-programmatically-save-visio-documents (https://docs.microsoft.com/en-us/visualstudio/vsto/how-to-programmatically-save-visio-documents)
As an observation, I would change the timestamp order to year,month, hour, minutes. The Windows naming takes a left right, alpha/numeric precedence. Thus, your files would be naturally sorted by name, then year, month, etc. Just a suggestion.
Hope the link helps.
Wapperdude
Is it possible to use a simple function like:
Private Sub Document_BeforeDocumentClose(ByVal doc As IVDocument)
ThisDocument.SaveAs "path\filename .vsd"
End Sub
where the "path\filename .vcd" should be something like "path\file()+DOCLASTEDIT().vsd"
the filename was created the first time the vsd was saved. What I need is a simple way to add a reference nr to my filename.