Solved

Accessing an existing Word Document

Posted on 2004-10-08
6
322 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 54

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 54

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

770 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