How to Save / Open a document without the workspace?

P

Paul

Hi,
When my application starts I create one visio drawing control and I open two
stencils. After saving a drawing the workspace appears to get saved as well
since opening the saved drawings will also open the stencils, meaning that I
now have 2 pairs of stencils instead of just 2 stencils.

Is there any way to:
1. Not save the workspace with the vsds.
2. I use Src to open a saved drawing, any way to tell it not to open the
drawing?
3. If the above aren't possible could someone suggest a different approach?

Thank you
 
P

Paul Herber

Documents.OpenEx does load the drawing, but how do I display it?

A plain documents.open should work and display the document. What else
is your code doing?
 
P

Paul

Hi Paul
My code is doing absolutely nothing else but trying to open the document (Im
using visio 2007)

I tried
this.axDrawingControl1.Window.Application.Documents.Open(@"E:\test.vsd");
or
this.axDrawingControl1.Document.Application.Documents.Open(@"E:\test.vsd");

I've tried both those in the page load as well as after a mouse click. I see
the document being added to the documents collection, but it just won't
display it. Any ideas?
 
P

Paul Herber

Hi Paul
My code is doing absolutely nothing else but trying to open the document (Im
using visio 2007)

I tried
this.axDrawingControl1.Window.Application.Documents.Open(@"E:\test.vsd");
or
this.axDrawingControl1.Document.Application.Documents.Open(@"E:\test.vsd");

I've tried both those in the page load as well as after a mouse click. I see
the document being added to the documents collection, but it just won't
display it. Any ideas?

What is the @ doing there?
Are you sure the file exists?
Does the document list show the correct file name?
Are you sure that the document isn't being displayed off screen? have
you tried menu Window -> Tile?
Is it displaying a window but the drawing is just not centered (and
the actual page is very off centre)?
Have you tried a different file? - This one is so obvious that I
hesitate to even mention it.
 
P

Paul

Hi JuneTheSecond,
My main problem is that regardless of the flags the drawing will not be
displayed. All I get is an empty page. I tried using open and openex but the
end result is the same. I am able to open stencils with OpenEx just no
drawings and at this point I have no idea what else to try (I also tried
using open / openex only after the page becomes visible without any luck).
Once again the document gets added to the documents collection and I know it
loads properly as I was able to select all the shapes copy them and paste
them onto a new page.

Here is the entire code:

private void Form1_Load(object sender, EventArgs e)
{
this.axDrawingControl1 = new
AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl();
this.axDrawingControl1.Enabled = true;
this.axDrawingControl1.Location = new System.Drawing.Point(12,
50);
this.axDrawingControl1.Name = "axDrawingControl1";
this.axDrawingControl1.OcxState =
((System.Windows.Forms.AxHost.State)(this.resources.GetObject("axDrawingControl1.OcxState")));
this.axDrawingControl1.Size = new System.Drawing.Size(1178, 726);
this.axDrawingControl1.TabIndex = 3;
this.Controls.Add(axDrawingControl1);
this.axDrawingControl1.Window.Application.Documents.Open(@"E:\test.vsd");
}

Thanks
 
P

Paul

What is the @ doing there?
Used to escape the '\' in the pathname, basically tells the compiler to
interpret everything coming after it as a string.
Are you sure the file exists?
I'm sure, trying to open a file that doesn't exist will throw an error in
visio.
Does the document list show the correct file name?
It does, I've selected all the shapes from this "invisible" document, copied
and pasted into a different document and they were correct.
Are you sure that the document isn't being displayed off screen? have
you tried menu Window -> Tile?
Is it displaying a window but the drawing is just not centered (and
the actual page is very off centre)?
Have you tried a different file? - This one is so obvious that I
hesitate to even mention it.
I took out the above code from my application in order to try and narrow
down the problem, perhaps what I'm doing wrong is something obvious?

Using axDrawingControl1.src = filename works but it opens the stencils as
well which is definitely not what I want.

Thank you
 
J

JuneTheSecond

I am sorry my answer was wrong.
I think vds file can not be opened in drawing control by open method, but by
src property. I think there is no other way to save drawing after removing
docked stencils to prevent displaying stencils again.
 
P

Paul

Thanks for your help.

I did switch to using .src however now I ran into another problem. My
application has a print preview option, and when this is activated I hide all
the child windows (its an mdi application). After closing print preview,
resetting the visible property to true for all the drawings, closing the last
drawing that was active and finally opening another one I get the following
exception:

A first chance exception of type 'System.AccessViolationException' occurred
in AxInterop.Microsoft.Office.Interop.VisOcx.dll
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.

If I don't hide the drawing controls while displaying the print preview
window the exception above isn't thrown.

Any idea why hiding the forms that contain the drawings and making them
visible again would cause any problems (all I'm doing really is changing the
visible property)?

Thanks
 
P

Paul

I forgot to mention that if that line is in a try catch block the exception
will be thrown yet the drawing still gets opened.
 
S

Stumple

I think I may be trying to do this too. Is the workspace the area on the
outer edges of the drawing grid? I would like to open a document without this
area.
 
P

Paul Herber

I think I may be trying to do this too. Is the workspace the area on the
outer edges of the drawing grid?

No, what you are referring to are the page margins, called Page Breaks
in Visio.

The workspace is the conglomeration of the current drawing with the
open stencils, toolbars and other windows.
 

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