• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Accessing an existing Word Document

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
dev-ngps7
Asked:
dev-ngps7
1 Solution
 
Julian HansenCommented:
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
 
yellowjetskiCommented:
* 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
 
Tommy HuiCommented:
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
 
dev-ngps7Author Commented:
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
 
Julian HansenCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now