Re: Programmatically save Visio drawing to a SharePoint Document Library

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Chris Roth [ Visio MVP ] (visioguy_at_reallyreallywarmmail.com)
Date: 01/12/05


Date: Wed, 12 Jan 2005 09:51:44 +0100

Is visSaveAsRO going to make the file read-only and screw up subsequent
saves (assuming you get it to work in the first place!) ???

-- 
Hope this helps,
Chris Roth
Visio MVP
"Al Edlund" <edlund@ameritech.net> wrote in message 
news:%23JBsrdA%23EHA.2180@TK2MSFTNGP12.phx.gbl...
> Lee,
> I always try to put error control into mine. You might try something like 
> this
>
> ' slightly different to catch any exceptions
> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button2.Click
>
>
> Dim VisApp As Visio.Application
> Dim VisViewer As AxVisOcx.AxDrawingControl
>
> try
>
>    VisViewer = AxDrawingControl1
>
>    VisApp = VisViewer.Document.Application
>
>    ' assume this wrapped because of message
>    VisApp.ActiveDocument.SaveAsEx("\\server1\sites\mysite\shared
>    documents\vsoBlank1.vsd", Visio.VisOpenSaveArgs.visSaveAsRO)
>
> catch err as exception
>
>        msgbox err.message
>
> end try
>
> End Sub
>
> Al
>
>
> "Lee Newson" <lee_newson@hotmail.com> wrote in message 
> news:uPiCVd$9EHA.3124@TK2MSFTNGP11.phx.gbl...
>> Hi Al,
>>
>> I am developing in VB.NET.
>>
>> I have no problems when saving to a local directory, it only appears to 
>> be a
>> problem when i try to save to a remote location.
>>
>> in terms of the full code, it is a windows application, with a form that 
>> has
>> the Visio Drawing Control on it.  If i change it to save to 
>> c:\vsoBlank.vsd
>> it saves without a problem, but as soon as i change it to a remote 
>> location
>> it gives the error, it doesn't seem to make any sense as when i tried 
>> saving
>> it to a remote location from visio itself it worked.
>>
>> the whole function looks like this:
>>
>> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles Button2.Click
>> Dim VisApp As Visio.Application
>>
>> Dim VisViewer As AxVisOcx.AxDrawingControl
>>
>> VisViewer = AxDrawingControl1
>>
>> VisApp = VisViewer.Document.Application
>>
>> VisApp.ActiveDocument.SaveAsEx("\\server1\sites\mysite\shared
>> documents\vsoBlank1.vsd", Visio.VisOpenSaveArgs.visSaveAsRO)
>>
>> End Sub
>>
>> I have tried using different VisOpenSaveArgs but to no avail, and using 
>> none
>> cause a problem because SaveAsEx is expecting at least one.
>>
>> I have also tried using SaveAs() and again it failed with the same
>> problem...
>>
>> Could not open http://server1/sites/mysite/shared 
>> documents/vsoBlank1.vsd.
>>
>> The only thing i haven't tried and as such will exist in my next attempt
>> will be to erase the old one... although i believe it will fail as 
>> before.
>>
>> Lee
>>
>>
>>
>>
>> "Al Edlund" <edlund@ameritech.net> wrote in message
>> news:OJ8T7d%239EHA.2196@TK2MSFTNGP14.phx.gbl...
>>> so it works as vba in the document but does not work in ????
>>>
>>> what's your development environment and what does the real code look 
>>> like
>>> (one liners can be incomplete ;-) )
>>>
>>> can your code save it successfully locally in a different directory?
>>>
>>> if you leave off the "visSaveAsWS+visSaveAsListInMRU" does it fail?
>>>
>>> before saving the new drawing, did you consider erasing the old one. I
>>> understand
>>> that you received no errors but would have expected to be warned 
>>> somewhere
>>> about overwriting an existing file....
>>>
>>> Al
>>> "Lee Newson" <lee_newson@hotmail.com> wrote in message
>>> news:eLFM9t89EHA.2568@TK2MSFTNGP11.phx.gbl...
>>> >I have some more information about this.  I opened Visio and recorded a
>>> > macro, saving a file to the document library.  I then tried uding the
>> same
>>> > line to save the programatically genereated drawing to Visio.  After 
>>> > the
>>> > first attempt failed i placed a blank visio drawing (vsoBlank.vsd) to
>> the
>>> > library and then tried saving a drawing with shapes on it to this 
>>> > file.
>>> >
>>> > At this point i did not receive any errors, however when i checked the
>>> > file
>>> > it was still blank.  so although the code did not cause an error and
>> cause
>>> > it to break, it did not save the document.  Is this a bug??
>>> >
>>> > this is the line i used to save the drawing:
>>> >
>>> > Application.ActiveDocument.SaveAsEx("\\server\sites\mysite\shared
>>> > documents\vsoBlank.vsd", visSaveAsWS + visSaveAsListInMRU)
>>> >
>>> > this is the same line as the macro recorder created so for all 
>>> > intensive
>>> > purposes it should work, right??
>>> >
>>> > If anyone actually reads this could you please reply as so far any
>>> > messages
>>> > i have put in any of the Visio newsgroups all appear to have been
>> ignored.
>>> >
>>> > Cheers
>>> >
>>> > Lee
>>> >
>>> >
>>> > "Lee Newson" <lee_newson@hotmail.com> wrote in message
>>> > news:uTZ0suy9EHA.3472@TK2MSFTNGP14.phx.gbl...
>>> >> Hi,
>>> >>
>>> >> I am trying to programmatically save a Visio drawing 
>>> >> (programmatically
>>> >> created) to a Document Library on SharePoint.
>>> >>
>>> >> I have tried using the SaveAs() method as the SDK says that this 
>>> >> method
>>> > can
>>> >> save to a UNC.
>>> >>
>>> >> Avery time i try thisi get an error message saying that it was unable
>> to
>>> >> open the specified location.  This is odd becuase the application i 
>>> >> am
>>> >> creating can open from the same document library.
>>> >>
>>> >> does anyone have any ideas??
>>> >>
>>> >> cheers for any and all help
>>> >>
>>> >> regards
>>> >>
>>> >> Lee
>>> >>
>>> >>
>>> >
>>> >
>>>
>>>
>>
>>
>
> 

Quantcast