Shapes.AddPicture file not found (error '800a1420')

R

Rod Behr

An ASP application creates and populates a word document using standard
VBScript.

Using the Shapes.AddPicture method I am able to insert a picture into a word
document when the picture resides on the IIS server. I can reference the
picture by drive letter or UNC path and it comes in fine. If, however, the
picture file resides on another server, I get the above error whether I use
UNC path or a mapped drive.

I have checked the filename and path: they are accurate. The syntax is
correct otherwise the AddPicture method would not work for local files. There
are no permission problem, as I can view the picture file in other
applications and bring it into Word manually.

What am I doing wrong? I can provide code if required.

Thank you.
 
D

David Horowitz

Rod,
Sounds like an interesting problem.
Are you really sure you understand which machine the ASP code is running on
and that that machine can see the remote files?
For example, are you sure this code is server-side script code and not
client-side?
Hmmm...
 
R

Rod Behr

David

Thanks for the response.

Yes, while fairly new to automating Word document design, I am an
experienced web designer. The ASP (traditional ASP) is server-side, sitting
on Server1 (for want of a better term). A file on a local drive relative to
Server1 (C:, D:, or F: in this case) as addressed as such
(C:\[path]\[filename]) or addressed as being
\\Server1\[share]\[path]\[filename] comes into the document fine. The
document is also being designed in a folder on Server1. There is no
JavaScript or any client-side scripting involved. A file addressed as
\\AnotherServer\[share]\[path]\[filename] causes the 800a1420 error.

I'm stumped. The site uses Windows authentication and while there may be
permission issues to sort out later when standard users need to use the site,
I have pretty close to domain admin rights and can open any of the files
myself. I can even pass the UNC path to IE7 as an address from a client PC
and IE7 displays the image.

Without including miles of code, the salient points would be:

Set WordApp = CreateObject("word.application")
Set WordDoc = WordApp.Documents.Add()
WordApp.Application.Visible = False
.....
xfileName = "\\AnotherServer\ECommerce\carbonmap.jpg"
Set picRange = WordDoc.Shapes.AddPicture(xfileName)

The error occurs on the last line. Earlier in the code, using the same
construct, a .jpg file on Server1 is inserted into the document without error.

Thanks again.
 
D

David Horowitz

Rod,
OK, glad to hear you know all the server admin issues involved. That makes
things easier.
Here's the thing I'm still wondering - you said
I can even pass the UNC path to IE7 as an address from a client PC
and IE7 displays the image.
Here's the thing, unless I'm misunderstanding you (quite possible).
The ASP code runs on the server, so you'd need to be able to pull up the
file from the server, not from the client.
That is, on the server, can you pull up the file in IE7 using the pathname
\\AnotherServer\ECommerce\carbonmap.jpg.
Also, even if you CAN pull it up in IE in a login session on the server,
when IIS tries to load the file, it's probably not running with the
credentials you are when you're logged in as an interactive login session -
IIS is logged in as another user (I'm not sure which), and IIS is the "user"
that needs to be able to see the file, so you need to make sure the IIS
login session can see AnotherServer and the ECommerce share.
Is this hitting the spot?
--
David Horowitz
Lead Technologist
Soundside Inc.
www.soundside.biz
Rod Behr said:
David

Thanks for the response.

Yes, while fairly new to automating Word document design, I am an
experienced web designer. The ASP (traditional ASP) is server-side,
sitting
on Server1 (for want of a better term). A file on a local drive relative
to
Server1 (C:, D:, or F: in this case) as addressed as such
(C:\[path]\[filename]) or addressed as being
\\Server1\[share]\[path]\[filename] comes into the document fine. The
document is also being designed in a folder on Server1. There is no
JavaScript or any client-side scripting involved. A file addressed as
\\AnotherServer\[share]\[path]\[filename] causes the 800a1420 error.

I'm stumped. The site uses Windows authentication and while there may be
permission issues to sort out later when standard users need to use the
site,
I have pretty close to domain admin rights and can open any of the files
myself. I can even pass the UNC path to IE7 as an address from a client PC
and IE7 displays the image.

Without including miles of code, the salient points would be:

Set WordApp = CreateObject("word.application")
Set WordDoc = WordApp.Documents.Add()
WordApp.Application.Visible = False
....
xfileName = "\\AnotherServer\ECommerce\carbonmap.jpg"
Set picRange = WordDoc.Shapes.AddPicture(xfileName)

The error occurs on the last line. Earlier in the code, using the same
construct, a .jpg file on Server1 is inserted into the document without
error.

Thanks again.
 
R

Rod Behr

David

Thanks again.

Not the spot, no, but we may be getting warmer. The images being inserted
into the Word document are themselves viewable on the website. IIS maps a
virtual folder to the image store on AnotherServer to access and display
them. Obviously Word has no access to this virtual parth and must access the
images from AnotherServer directly.

When browsing the website on Server1 (from within IIS and using IE7) I can
browse directly to \\AnotherServer to view the images. In terms of
permissioning, again, IIS is operating under Windows authentication and so
should replicate the priviledges of the client user, although I will
double-check this.

When building a Word document using VBScript and inserting a picture, what
user priviledges are requires for insertion? Web browsing obviously uses
read-only. Is a higher permission level required to insert an image into a
Word document?
 
R

Rod Behr

Furtehr testing:

If I open Word on Server1 and write the exact same code as a macro, the code
works, bringing in a picture from AnotherServer. Yet teh code fed to Word
from ASP refuses to work for pictures from other servers than the web server.

I'm flumoxed! I can find just about no references to error number 800a1420
on the net. Short of copying each file across to a temp directory on the
server, inserting it and then deleting the original file - which seems
terribly clumsy - I can think of nothing more.
 
R

Rod Behr

HOLD THAT THOUGHT!!

I CAN replicate the error manually within Word. This time, instead of
providing the string directly, I sourced it from the ADODB recordset as in
the ASP application.

The full code from within Word is:

Dim picturefile
Dim strSQL
Dim rs As Recordset
Dim conn As ADODB.Connection

Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset

conn.ConnectionString = "DSN=TheFactory;DATABASE=xxx;Uid=xxx;Pwd=xxx"
conn.Open
strSQL = "SELECT Picture FROM QuoteLineItems WHERE QuoteID=456"

rs.Open strSQL, conn

Do While Not rs.EOF
Selection.InlineShapes.AddPicture (rs("Picture")) <--- ERROR OCCURS HERE
rs.MoveNext
Loop

Word reports the error as 5152 (not 800a1420 as IIS reports it). KB178878
acknowledges the problem, although isn't particularly helpful - it uses the
Dialogs command, which I do not have available to me when creating the
document from outside Word.

Given the new error code, I shall have more of a hunt for a solution, but if
you are able to shed any light on this I would be most grateful.
 
R

Rod Behr

Nope... we're back to square one.

One of the entries in the data table was, in fact, an invalid filename
(well, stored as a URL and not a UNC). I cursed myself for what appeared to
be a newbie error and corrected the data. Now the code runs perfectly in
Word, but I get the same errors in ASP - i.e. Word will bring the data in
from the database and use the Selection.InlineShapes.AddPicture(picName)
method fine, but using this from within IIS returns the 800a1420 error.

Dang! I was THIS close...

Again, please, help!
 
D

David Horowitz

Rod,
Let's try rewriting the line of code in several different ways. It seems the
script parser may like slightly different syntax than VBA macros in Word,
and as you know it won't give you much syntax error info.
You said you're current code line is:
Set picRange = WordDoc.Shapes.AddPicture(xfileName)
so, let's try the following options and just see if anything comes through:
1. WordDoc.Shapes.AddPicture xfileName
2. Call WordDoc.Shapes.AddPicture(xfileName)
3. WordDoc.Shapes.AddPicture xfileName
4. Set picRange = WordDoc.InlineShapes.AddPicture(xfileName)
5. Call WordDoc.InlineShapes.AddPicture(xfileName)
6 .WordDoc.InlineShapes.AddPicture xfileName
You can also try
Set objs = WordDoc.Shapes
objs.AddPicture ...
or
Set objs = WordDoc.InlineShapes
objs.AddPicture ...
Let us know!
 
R

Rod Behr

I'm back on this one after a week distracting myself with other aspects of
this project.

I've tried re-phrasing it as you have suggested, but no joy. As I said, if
the file is local it comes in fine, if the file is to be retrieved across the
network the "file not found" error is triggered.

Any other ideas?
 

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