Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapped Drive Problem

Status
Not open for further replies.

angiem

MIS
Sep 29, 2000
116
0
0
CA
Hi

I have an app that opens and inserts a photo into a word template. The problem is inserting the photo the photo resides on a storage device attached to the network. I'm using a mapped drive and I get an error message saying it is not a valid file name.

this is the code

Code:
        Dim objWordApplication As New Application
        Dim objDocument As New Word.Document
        objDocument = objWordApplication.Documents.Add (OTemp)
        Dim v_range As Word.Range
         v_range.InsertParagraph()
                    '                     
                    With objWordApplication.Selection
                        .InlineShapes.AddPicture( _
                          filename:="Z:\winter.jpg", _
                          LinkToFile:=False, _
                          SaveWithDocument:=True, _
                            Range:=v_range)
                    End With
Any help would be greatly appreciated.

 
the mapped drive must be on the server, not the client. this is often missed when debugging because the client and server are the same development box

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I've tried that to and that gave me the same error message
 
then it's a security issue.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Can you elaborate more, I've given the user full control what else do I need to do.
 
the user doesn't need full control. only enough to read/write files. the account which is running IIS must have access to the template file and the remote drive.
if the remote drive is another server, you will also need to setup delegation to pass credentials from IIS to the remote box.

before you dig to much deeper into this have you confirmed you can access the files using a simple test

create a page which opens each file independently.
Code:
protected override void OnLoad(EventArgs e)
{
   if(!File.Exists("path to ms word tempalte"))
   {
      throw new Exception("Cannot access template file.");
   }

   if(!File.Exists("path to image"))
   {
      throw new Exception("Cannot access image file.");
   }
}
if the page loads without error than something is wrong with your code. If an exception is thrown then you have either an invalid file path or denied access

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top