Solved

Error Accessing Word Document

Posted on 2006-06-16
9
181 Views
Last Modified: 2010-04-23
My application pulls some patient data from a table and prints it on a Word Document.
It is working fine for one user, but the other user gets the "error Accessing Word Document". The word docs are on a network share. When I setup the second user, she initially got the same error, but it went away when I gave her permissions on the folder where the docs are stored. Both users have the same permissions, and the drive and folder are accessible to both.The docs used by the App are in a folder that only these two users have access to( and me of course), so I know that it is not a file lock issue. Where else should I look to see why the one user cannot access the word docs?
0
Comment
Question by:hexOffender
[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
  • 5
  • 4
9 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 16919986
Do they have the same version of Word installed on their PC. If you are using early binding you have to make sure that the Word verrsion is the same as referenced library
0
 

Author Comment

by:hexOffender
ID: 16920359
I bet thats it, she has Word 2002 and I and the working user have Word 2003.
Can you esplain more about the early vs. late binding? Well more to the point, what is the way to make this work for all the versions ( at least the most recent ones)
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 16920673
During an early binding you create a reference to the Word object. During late binding you create an object at a run time. Late binding will use the version of the Word existing on the user PC

Example
'early - ref to Excel Lib
        '        Dim testexcel As New Excel.Application()
'Late - no ref
        Dim testexcel As Object
        testexcel = CreateObject("Excel.Application")
... code...

a few pro's and con's for early and late binding.

early binding
pro's
- Ease of developing, in the VB-IDE, when using early binding, you have have context sensitive help,
dropdowns and other stuff which makes developing very productive.
- Faster, early bound code executes faster, because it doesn't have to search the registry for registration
 information, cause it is compiled into the exe

con's
- If the target computer does not have the file, an error will ocuur which can't be trapped, forcing
the application to quit without terminating properly, so no unload events are triggered, which can lead
to memory leaks and stuff
- Version dependant. When using early bound refferences, if a file is found, but the version is lower,
the program will give an error and quit in the way described above.


late binding
pro's
- Trappable errors: If a file cannot be found, a runtime error occurs which can be trapped, enabeling you
to execute other code to terminate the application the way it should.
- Version independant. If you don't specify a version, the system will use the highest version it finds. So if
a computer needs ADO, like say 2.5, and the target computer only has ADO 2.1 installed, there's a chance
the program still works as it should, if not version dependant functions are used.
- Flexibility: when using late bound, you can create objects when you only have the name. You can even
use strings which hold the name of the object, and create it from that.
- Polymorphism: this is a more advanced topic, but I'll just stick to the fact that this can only be done using
late bound objects
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

Author Comment

by:hexOffender
ID: 16921317
Ok,
here is the code i am using,

Dim wordApp As Word.Application
wordApp = CreateObject("Word.Application")
Dim wordDoc = New Word.Document

So which type of binding would you say it is?
0
 

Author Comment

by:hexOffender
ID: 16921354
Ok I see now , I am late binding as I create the object at runtime, but that does not explain why the error with access to the Documents.
0
 

Author Comment

by:hexOffender
ID: 16921378
just some more info,

I am using the reference to Office 11, If I used a reference to Office 10 instead would that work, using the lowest Installed version?
0
 
LVL 28

Accepted Solution

by:
iboutchkine earned 125 total points
ID: 16921548
Dim wordApp As Word.Application
wordApp = CreateObject("Word.Application")
Dim wordDoc = New Word.Document

it is early binding. and it means that you have reference the word object. Which one do you reference 10 or 11.
You cannot reference both. And if user uses the other version of Word it will not work.
For users with different Word use late binding

      Dim w As Object
       w= CreateObject("Word.Application")

and you don't need the refernce
0
 

Author Comment

by:hexOffender
ID: 16922162
yep that totally worked.
Can I remove the COM reference, or do I still need it?
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 16922185
yes if you are using late binding , you can remove com reference
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

635 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