Opening word from my application
hi,
i m creating some application with diffrent kind of users.
in my application i want to open a word document.
problem is that some users can view and update the file and others can only view it.
anyone know how can i open the word file with read write permissions??
thanks,
ohad.
Re: Opening word from my application
Before opening the document read the user name and decide if he/she is allowed to modify it.
If a user is allowed to modify the file you can just open it. If user is not allowed to modify the document, copy it first into different one and open it. When user has finished with it delete it.
Iouri Boutchkine
[email protected]
Re: Opening word from my application
Code:
'Tis open a doc readonly, but user can modify it and save it with
' a different name
Option Explicit
Dim wdapp As word.Application
Dim wdocs As word.Documents
Private Sub Command1_Click()
Set wdapp = New word.Application
wdapp.Visible = True
Set wdocs = wdapp.Documents
'open sintax: the_pathName_to_doc,confirm_Conversions,readonly
wdocs.Open "c:\doc1.doc", False, True
End Sub
'you have to correct manage these commands:
wdocs.Close 'only if documents.count >0
Set wdocs = Nothing
wdapp.Quit ' only if not closed within word (you can find it
'declaring word withevents and intercepting the quit event.
'Beware, there is a difference between ide and compiled)
Set wdapp = Nothing
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Re: Opening word from my application
what control/object do i need to add to my project so i could use this code?
thanks,
ohad.
Re: Opening word from my application
Put a reference to Microsoft word 8.0 (or 9.0) object library
(via menu -> project ->;references)
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Re: Opening word from my application
..and add a command button to a form.
By teh way, to see how to use event Quit, have a look here:
http://codeguru.com/cgi-bin/bbs/wt/s...age=&view=&sb=
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Re: Opening word from my application
i add the word 9.0 tlb and i tryed running your code but i get an automation error about the line:
set wdApp=new word.application
any suggestions?
thanks,
ohad
Re: Opening word from my application
reference microsoft word 9.0 Object library (file should be "MSWORD9.OLB"). This require word to be installed on your PC. Iouri once said you may do the same without having Word installed (you should ask him if this is the case)
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Calling MS Word from VB application
I have the following dilemma.
I made an app using VB6, Win XP (O/S is not really relevant anyway), and Office 2002 Pro installed and it needs to call MS Word to load a document. The app works fine, and its installables are fine on any PC with Office 2002 installed on it.
I installed the app on a second PC (again I added the MSWORD10.OLB to the references, and shipped it with the distributables), with that PC having Word 2000 and Office 2002 installed. That too was fine.
I uninstalled Office 2002 on the second PC, re-installed (to put MSWORD10.OLB back on it) re-run the app, and – CRASH! An error – at the following VB line.
Code:
Set WordApp = New Word.Application
Same result with running it as executable and from within VB6.
I then added MSWORD9.OLB (because it was Word 2000) to the references, and this had no effect, - still not working. If I re-install Office 2002 on the 2nd PC and re-run the app, – it’s OK again…
I need to have this app to work on a PC having Word 2000 or Word 2002. (and earlier versions of Word would be good) Where Am I going wrong??
VB6 doesn’t seem to like me having a reference to both MSWORD9.OLB and MSWORD10.OLB with the same app. It just takes MSWORD10.OLB as the referenced object if I attempt to apply both, but I can ship both objects with the App.
I need help! And I am open to suggestions here. – How do I get an app to work with any (almost) version of Word installed on the client PC?, If possible, I would like some magic code :-s
Jason.