Solved

Accessing an existing Word Document

Posted on 2004-10-08
6
296 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
6 Comments
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
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
Comment Utility
* 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
Comment Utility
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
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now