Solved

Accessing an existing Word Document

Posted on 2004-10-08
6
347 Views
Last Modified: 2010-04-17
Here is a tough and confusing problem i have, please consider the following code

actDoc = WordApp.Documents.Open(arrStringPath(intFileCount))

actDoc is of type Word.Document
WordApp is of type Word.Application
arrStringPath has the pathname of the word document

When debugging, this message appears as the line of code above is processed

* no user rights (i have sufficient rights)
*document name of path invalid (all path names are stored in the array)

I have used a watch to confirm pathnames are being input into the array

0
Comment
Question by:dev-ngps7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 12258689
Not quite sure what you are trying to do - maybe post more source code. Also more information on the exact error you are getting would help.

I knocked this together very quickly

Dim WordApp As Word.Application
    Dim actDoc As Word.Document
    Dim arrStringPath(3) As String
    Dim i As Integer
   
    arrStringPath(1) = "d:\trash\docs\doc1.doc"
    arrStringPath(2) = "d:\trash\docs\doc2.doc"
    arrStringPath(3) = "d:\trash\docs\doc3.doc"
   
    Set WordApp = CreateObject("Word.Application")
    WordApp.ShowMe
   
    For i = 1 To 3
        Set actDoc = WordApp.Documents.Open(arrStringPath(i))
        actDoc.Close False
    Next
   
    WordApp.Quit False

Seems to work fine. Maybe add the Set command before actDoc = ...
0
 
LVL 3

Expert Comment

by:yellowjetski
ID: 12258720
* no user rights (i have sufficient rights) - If you are running this program in the wwwroot directory, I am sure that the default user is the IIS user which does not have ANY right to open or edit files outside of that directory.

*document name of path invalid (all path names are stored in the array) - This would be related to the problem above or make sure is the absolute path.

Hope that guide you in the right direction.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 12268596
Sounds like you are trying to do this from ASP or ASP.NET or a service. Regardless of which, it sounds like you are trying to refer to a part of the disk drive that the account the program is running under doesn't have access to. You should probably try setting up the account for the service to a known account or give the account access rights to the folder.
0
 

Author Comment

by:dev-ngps7
ID: 12317443
I wish to close this thread due to the fact that i accidently opened up more threads with the same sort of question. For this, i can only  apologise as i am new to Experts Exchange. This problem can be further discussed here:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21166350.html

Sorry for the inconvenience caused.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 12317532
with reference to this thread and http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21166350.html

Just a point - the questions asked in the two threads are different. In this thread you are asking about solving an error you have been receiving and you received answers to those (that you did not respond to).

In the other thread you are asking something completely different i.e. how to access a Word Document without creating a Word Object - and you received answers to that to - basically you can't.

In neither of the threads have you provided any feedback to the questions posted. If you people to assit you you need to assit them by providing the right information and feedback to posts.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Starting up a Project

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question