Finding file format of a Visio document

P

Peter Smithson

Hi,

I'm having problems programatically saving Visio files in the desired
format or finding out what version they were saved in.

I'm using Visio 2003 to open a 2002 document.

So far I have found that I can use SaveAs from the document object to
always save the document in 2003 format without any prompting (despite
any settings in the Tools->Options->Save tab).

If I replace the SaveAs call with a simple Save call, it will always
prompt despite un-ticking the "Show File Save Warnings".

This might be enough functionality to do what I want depending on
configuration options of the product I'm developing BUT - how do I
find out what version the document is in?

Obviously, the "Version" method would be a good start but it always
reports the current version (the documentation mentions that the
documents are converted on the fly when opened to the latest
version). There are some other version functions but they all return
the latest version. The Version method seems to be just for changing
the format to be saved in.

So, other than finding out the original version of the document,
another acceptable solution would be if I could specify the file
version in the SaveAs but I don't think I can.

Thanks.

Peter.
 
P

Peter Smithson

another acceptable solution would be if I could specify the file
version in the SaveAs but I don't think I can.

Doh! Of course I can. I just told myself I could with the Version
property.

So the only question that remains (since setting it explicitly every
time is not ideal) is, how do I know what version the file was in?

Thanks.

Peter.
 
P

Paul Herber

So the only question that remains (since setting it explicitly every
time is not ideal) is, how do I know what version the file was in?

I don't think you can know that. Some of Microsoft's own shapes
contain a custom property or use defined cell showing the version
number e.g. the month shape in the Calendar shapes stencil has a
user-defined cell User.visVersion.
 
P

Peter Smithson

I don't think you can know that. Some of Microsoft's own shapes
contain a custom property or use defined cell showing the version
number e.g. the month shape in the Calendar shapes stencil has a
user-defined cell User.visVersion.

One thing I found here -

http://blogs.msdn.com/visio/archive/2006/07/07/657375.aspx

was a comment from the Visio team in reply to "Is there any way to
tell by looking at the file which version it is?" they said "I don't
think this can be done without writing some code to check the version.
". Unfortunatley, you can't comment on blog entries older than 60
days so I can't ask for the code. Ah well.
 
J

John

Hello Peter,

Try the code below. Should give you the idea.

Best regards

John

Public Sub SetAppVersion()
Dim shpSelected As Visio.Shape
If Not Application.ActiveWindow.Selection Is Nothing Then
Set shpSelected = Application.ActiveWindow.Selection.PrimaryItem
If SetVersionProps(shpSelected) = True Then
MsgBox "Application version set in " & shpSelected.Name,
vbOKOnly
Else
MsgBox "Application version NOT set in " & shpSelected.Name,
vbOKOnly
End If
End If
End Sub

Private Function SetVersionProps(ByRef shpIn As Visio.Shape) As Boolean
If shpIn.CellExists("User.visVersion", False) = True Then
SetVersionProps = True
shpIn.Cells("User.visVersion").Formula = Application.Version
Else
SetVersionProps = False
End If
End Function
 
P

Peter Smithson

Hello Peter,

Try the code below. Should give you the idea.

Hi John,

I think that's setting my own version number. We already have one of
those which allows us to see which version of our product the drawing
was saved under. The problem here is I want to know what version of
Visio was used to save the document. We could add that in now as
another user version number but, as there's 100's of drawings out
there without this info, it's too late.

Let me know if I mis-understood.

Thanks.

Peter.
 
P

Paul Herber

One thing I found here -

http://blogs.msdn.com/visio/archive/2006/07/07/657375.aspx

was a comment from the Visio team in reply to "Is there any way to
tell by looking at the file which version it is?" they said "I don't
think this can be done without writing some code to check the version.
". Unfortunatley, you can't comment on blog entries older than 60
days so I can't ask for the code. Ah well.

What about the ...documents.item[n].version property? That returns an
integer which should be the version the file was last saved at.
 
J

JuneTheSecond

How would you like to use Document.FullBuildNumberCreated?
There is an example in HELP.
Next code is from HELP, and edited main-proc a littlet to get document not
opened.

Public Sub FullBuildNumberCreated_Example()

Dim lngFullBuild As Long
Dim doc As Visio.Document

Set doc = GetObject("Full Path Name")

lngFullBuild = doc.FullBuildNumberCreated
ParseFullBuildNumberCreatedProperty (lngFullBuild)
Set doc = Nothing
End Sub
 
J

JuneTheSecond

How would you like to use dDocument.FullBuildNumberCreated property?
There is an example in HELP.
Next code is from help. and edited a little to get file not opened.

Public Sub FullBuildNumberCreated_Example()

Dim lngFullBuild As Long
Dim doc As Visio.Document

Set doc = GetObject("Full Path File Name")

lngFullBuild = doc.FullBuildNumberCreated
ParseFullBuildNumberCreatedProperty (lngFullBuild)
Set doc = Nothing
End Sub
 
J

JuneTheSecond

how woukd you like to use Document.FullBuildNumberCreated property?
There ia an example in HELP.
Next code is from help, and edited a little to get file not opened.

Public Sub FullBuildNumberCreated_Example()

Dim lngFullBuild As Long
Dim doc As Visio.Document

Set doc = GetObject("Full Path File Name")

lngFullBuild = doc.FullBuildNumberCreated
ParseFullBuildNumberCreatedProperty (lngFullBuild)
Set doc = Nothing
End Sub
 
J

JuneTheSecond

How would you like to use

Public Sub FullBuildNumberCreated_Example()

Dim lngFullBuild As Long
Dim doc As Visio.Document Document.FullBuildNumberCreated property?
There is an example in Help.
Next code is from help, and edited a littel to get a file not opened.

Set doc = GetObject("Full Pth File Name")

lngFullBuild = doc.FullBuildNumberCreated
ParseFullBuildNumberCreatedProperty (lngFullBuild)
Set doc = Nothing
End Sub
 
J

JuneTheSecond

How would you like to use Document.FullBuildNumberCreated property or
Document.FullBuildNumberEdited property?
There are examples inHelp.
Next code is from Help, and edited a little to get a file not opened.

Public Sub FullBuildNumberCreated_Example()

Dim lngFullBuildCreated As Long
Dim lngFullBuildEdited As Long
Dim doc As Visio.Document

Set doc = GetObject("Full Path File Name")

lngFullBuildCreated = doc.FullBuildNumberCreated
lngFullBuildEdited = doc.FullBuildNumberEdited
ParseFullBuildNumberCreatedProperty (lngFullBuildCreated)
ParseFullBuildNumberCreatedProperty (lngFullBuildEdited)
Set doc = Nothing
End Sub
 
P

Peter Smithson

How would you like to use Document.FullBuildNumberCreated property or
Document.FullBuildNumberEdited property?

I'm pretty sure they are the other version functions I tried and found
to always return the latest version but I will re-try them since you
seem to think they resolve the problem.

Peter.
 
P

Peter Smithson

I'm pretty sure they are the other version functions I tried and found
to always return the latest version but I will re-try them since you
seem to think they resolve the problem.

Yes - I can confirm they do the same as Version in that they just
return the latest value. I'm opening a project created in 2002 and
comparing it to a 2003 one. I even re-created the 2002 project just
in-case I had used 2003 and done a save in 2002 format from there.

Peter
 
P

Paul Herber

What about the ...documents.item[n].version property? That returns an
integer which should be the version the file was last saved at.

Can't find an "item" method off the document object. It's not
documented here -

http://msdn2.microsoft.com/en-us/library/aa175547(office.11).aspx

It's not mentioned in the Version documentation either -

http://msdn2.microsoft.com/en-us/library/aa176861(office.11).aspx

In that case just use the documents array or thisDocument or whatever
the language gives you access to.
 
P

Peter Smithson

In that case just use the documents array or thisDocument or whatever
the language gives you access to.

I believe the language (C++) gives me access to any of the documented
Visio methods and properties. There is no documented Version
available in the places you mention. Where it is available (on the
document object or application object), it just returns the current
version.
 
P

Paul Herber

I believe the language (C++) gives me access to any of the documented
Visio methods and properties. There is no documented Version
available in the places you mention. Where it is available (on the
document object or application object), it just returns the current
version.

It's in the Visual Basic help, search for version then select the
Document Object section.
 
J

JuneTheSecond

How would you like to use Document.FullBuildNumberCreated property or
Document.FullBuildNumberEdited property?
There are examples inHelp.
Next code is from Help, and edited a little to get a file not opened.

Public Sub FullBuildNumberCreated_Example()

Dim lngFullBuildCreated As Long
Dim lngFullBuildEdited As Long
Dim doc As Visio.Document

Set doc = GetObject("Full Path File Name")

lngFullBuildCreated = doc.FullBuildNumberCreated
lngFullBuildEdited = doc.FullBuildNumberEdited
ParseFullBuildNumberCreatedProperty (lngFullBuildCreated)
ParseFullBuildNumberCreatedProperty (lngFullBuildEdited)
Set doc = Nothing
End Sub
 
P

Peter Smithson

It's in the Visual Basic help, search for version then select the
Document Object section.

That is the one I tried and was refering to in my original post.
 

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