programmatically inserting a picture (.bmp)

  • Thread starter Amedee Van Gasse
  • Start date
A

Amedee Van Gasse

Hello,

First I'd like to say that until 3 weeks ago, I didn't know much about
Visio (I hadn't even used it myself), but I know my

way around in other MS Office software and I'm familiar with VBA.

One of the homebrew apps here (something written in Access, I presume,
by someone in another department) creates Visio

files. Certain .bmp files have to be inserted, depending on whatever
the user configures in the Access app. There are only

one or two real users of this app, at least for the part of it that
creates the Visio files. (AFAICT)

Every few weeks or months, our helpdesk gets complaints from one of
the users that the pictures aren't properly inserted.

Instead there is a black square/rectangle with the filename below it.
Restoring an image of the users' hard disk solves

the problem, until a few weeks or months later.

This problem was escalated to me for a permanent solution. I did a bit
of research, and I discovered there are two ways to

programmatically add a picture:
* the Page.InsertFromFile method (to add a linked or embedded OLE
object)
* the Page.Import method (to add a new shape directly into Visio as if
it were any other regular Visio shape, no linking

or embedding)

I have not yet discussed this issue with the original developer, nor
have I had a look at the source code (yet). However,

because I am "the new guy", and because my predecessor didn't have
much success in solving this issue, I wanted to do some

research (and ask advice here on the newsfroups) before I make a fool
of myself. Can I please have your comments on the

following?

* InsertFromFile inserts an object that is still linked to the
original file
* Linking results in a smaller Visio file because the file itself
isn't added, just a reference to it.
* There is more cpu overhead because an external program has to be
loaded to process the linked file.
* When the source image is moved or renamed, you lose the image in
Visio.
* InsertFromFile "smells like" the casting of ancient Win3.x runes and/
or dirrrty registry hacks. That's my first

impression when I saw the "Microsoft Object Packager".
* Import just adds a copy of the image file as a shape, there is no
link back to the original file
* This results in a slightly larger Visio file, but the file increase
is negligable - it concerns just a few 30kb images.
* You can do whatever you want with the original images: move, rename,
delete, it won't matter. You can even move the

Visio file off the network and the images will still be available.
* For simple and small bitmaps, importing is preferred over linking.
(my conclusion)

I'm quite sure my collegue-I-have-not-yet-met has used InsertFromFile
(or something similar), because I have a Visio file

created by his app, and the image (or what should be an image),
behaves like a linked object.
Also his app throws an error when the Visio file is created: error 462
The remote server machine does not exist or is

unavailable. The function CreateObject requires a valid server. For
this error the following cause and solution are

possible: A server parameter is given but the server could not be
reached or found. (translated back from Dutch to English

so the original English error message might be a bit different). My
instinct tells me that the broken image links and the

error message are related.

Should I tell my collegue to search & destroy^Wreplace every instance
of Page.InsertFromFile with Page.Import? Any other suggestions?

TIA,
 
P

Paul Herber

Hello,

* Import just adds a copy of the image file as a shape, there is no
link back to the original file
* This results in a slightly larger Visio file, but the file increase
is negligable - it concerns just a few 30kb images.
* You can do whatever you want with the original images: move, rename,
delete, it won't matter. You can even move the
Visio file off the network and the images will still be available.
* For simple and small bitmaps, importing is preferred over linking.
(my conclusion)

From my reading of what your application requires then this is the
method you need.
Should I tell my collegue to search & destroy^Wreplace every instance
of Page.InsertFromFile with Page.Import? Any other suggestions?

you might also want to check the flag setting used with
InsertFromFile, the second parameter being whether to use a link or to
embed the object ( link = visInsertLink ).
P.S. you will also need to remove the flag parameter in the search
and replace.
 
A

Amedee Van Gasse

From my reading of what your application requires then this is the
method you need.

I was able to convince my collegue to modify his program.
There were some other minor issues, but nothing he couldn't solve
himself.
The program also works *much* faster now = happy end users.
Thank you for the advice.
 
P

Paul Herber

I was able to convince my collegue to modify his program.
There were some other minor issues, but nothing he couldn't solve
himself.
The program also works *much* faster now = happy end users.
Thank you for the advice.

A happy customer - result.
 

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