Batch Conversion

D

DBLondon

I have been a Visio user for almost 10 years now so I have hundreds of
files. However, some of my colleagues use a mac program called
Omnigraffle Professional (a much watered down Visio-style application)
which only accepts Visio drawings in the xml format (.vdx)

I would like to perform a batch conversion of vsd files to the vdx
format in order to share my files with the mac users. Is anyone aware
of such a tool being available for license or purchase or does Visio
itself have a tool for batch conversions of vsd files to vdx. Doing a
'save as' process for over 300 visio drawings one by one will take
hours and is tedious to say the least. Thanks in advance.
 
D

DBLondon

I have Visio 2002 and 2003 some of the files are very old. But lets
say I can use Visio 2002 if its easier.
 
D

Dick Hamilton [MSFT]

Hi,

You can use Visio VBA automation to loop through a given folder of drawings,
open and save them one at a time to another folder in the VDX format. You
can get to the Visio Visual Basic Editor in a blank drawing by selecting
Tools > Macro > Visual Basic Editor (or Alt+F11). Here is sample code to
demonstrate this ability:

'DESCRIPTION: Saves all of the VSD files in a given folder as VDX files



'Change to match the folder that contains all of the VSD files you want to
convert

Private Const SOURCEPATH As String = "c:\temp\source"



'Change to match the folder where you want the VDX files to be saved to. The
folder must exist.

Private Const TARGETPATH As String = "c:\temp\target"



Public Sub Main_()



ConvertVSDToVDX SOURCEPATH, TARGETPATH



End Sub





Private Sub ConvertVSDToVDX(sourceFolder As String, targetFolder As String)



Dim docToSave As Document

Dim sourceFile As String



On Error GoTo ConvertVSDToVDX_ErrorHandler



sourceFile = Dir$(sourceFolder & "\" & "*.vsd")



If sourceFile <> "" Then



Do

'NOTE: You might need to use Application.AlertResponse to
automatically

'respond to any dialogs that appear as a result of opening a
document



'Open the source vsd

Set docToSave = Application.Documents.OpenEx(sourceFolder & "\"
& sourceFile, visOpenRO)

'Save the document to vdx. Original file name minus extension is
used.

docToSave.SaveAs targetFolder & "\" & Left$(docToSave.Name,
Len(docToSave.Name) - 4) & ".vdx" 'assume 4 character extension

'Ensure we aren't asked to save and close the doc

docToSave.Saved = True

docToSave.Close

'Clean up the doc object

Set docToSave = Nothing



sourceFile = Dir$



Loop While (sourceFile <> "")



End If



Exit Sub



ConvertVSDToVDX_ErrorHandler:

Dim choice As Integer

choice = MsgBox("An error has occurred!" & vbCrLf & vbCrLf &
Err.Description & vbCrLf & vbCrLf & "Continue?", vbCritical + vbYesNo, "Save
As VDX Error")

If choice = vbYes Then

Resume Next

Else

Stop

End If



End Sub
 
D

Dick Hamilton [MSFT]

Hi,

You can use Visio VBA automation to loop through a given folder of drawings,
open and save them one at a time to another folder in the VDX format. You
can get to the Visio Visual Basic Editor in a blank drawing by selecting
Tools > Macro > Visual Basic Editor (or Alt+F11). Here is sample code to
demonstrate this ability:

'DESCRIPTION: Saves all of the VSD files in a given folder as VDX files

'Change to match the folder that contains all of the VSD files you want to
convert
Private Const SOURCEPATH As String = "c:\temp\source"

'Change to match the folder where you want the VDX files to be saved to. The
folder must exist.
Private Const TARGETPATH As String = "c:\temp\target"

Public Sub Main_()
ConvertVSDToVDX SOURCEPATH, TARGETPATH
End Sub

Private Sub ConvertVSDToVDX(sourceFolder As String, targetFolder As String)
Dim docToSave As Document
Dim sourceFile As String
On Error GoTo ConvertVSDToVDX_ErrorHandler
sourceFile = Dir$(sourceFolder & "\" & "*.vsd")

If sourceFile <> "" Then
Do

'NOTE: You might need to use Application.AlertResponse to
automatically
'respond to any dialogs that appear as a result of opening a
document

'Open the source vsd
Set docToSave = Application.Documents.OpenEx(sourceFolder & "\"
& sourceFile, visOpenRO)

'Save the document to vdx. Original file name minus extension is
used.
docToSave.SaveAs targetFolder & "\" & Left$(docToSave.Name,
Len(docToSave.Name) - 4) & ".vdx" 'assume 4 character extension

'Ensure we aren't asked to save and close the doc
docToSave.Saved = True
docToSave.Close

'Clean up the doc object
Set docToSave = Nothing
sourceFile = Dir$

Loop While (sourceFile <> "")

End If

Exit Sub

ConvertVSDToVDX_ErrorHandler:

Dim choice As Integer
choice = MsgBox("An error has occurred!" & vbCrLf & vbCrLf &
Err.Description & vbCrLf & vbCrLf & "Continue?", vbCritical + vbYesNo, "Save
As VDX Error")

If choice = vbYes Then
Resume Next

Else
Stop
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top