|
-
Nov 13th, 2000, 11:39 AM
#1
Thread Starter
Hyperactive Member
I have developed a database application that has a memo field tied to a RichTextBox. I have added the neccessary code to send the contents of the RichTextBox to Word through automation and it works fine.
My questions are thus:
1)I am using Word 2000 on my system and have included the neccessary References to enable the above to work. Will this work if the user has word 97 instead. Some of our user have Word 97 while others have Word 2000? If not, what needs to be done to do so?
2)In the event that the user does not have Word on his computer at all, how can I check and automatically disable this menu option so that I don't get an error?
Thanks,
Rev. Michael L. Burns
-
Nov 13th, 2000, 11:51 AM
#2
Fanatic Member
Rev Burns,
I use this code in almost any Automation script I am writing. I find it invaluable…
Code:
Function AddReference(strFileName As String) As String
Dim ref As reference
Set db = CurrentDb
On Error GoTo Error_ReferenceFromFile
Set ref = References.AddFromFile(strFileName)
AddReference = "OK"
Exit_ReferenceFromFile:
db.Execute "insert into tblReferenceLog (event_time, action, result) " & _
"select #" & Now & "#, 'Removing Reference', '" & AddReference & "'"
Exit Function
Error_ReferenceFromFile:
AddReference = Err.Number & " " & Err.Description
Resume Exit_ReferenceFromFile
End Function
Function RemoveReference(strLocalName As String) As String
Dim ref As reference
Set db = CurrentDb
On Error GoTo Error_RemoveReference
Set ref = References(strLocalName)
' Remove calendar control reference.
References.Remove ref
RemoveReference = "OK"
Exit_RemoveReference:
db.Execute "insert into tblReferenceLog (event_time, action, result) " & _
"select #" & Now & "#, 'Adding Reference', '" & RemoveReference & "'"
Exit Function
Error_RemoveReference:
RemoveReference = Err.Number & " " & Err.Description
Resume Exit_RemoveReference
End Function
Explanation:
AddReference(“C:\Progam Files\Microsoft Office\Office\MSWORD8.olb”) would add the Word 8.0 reference. The theory is that if Word is not present, it will throw up an error (which you can handle whichever way you wish – I use a table called tblReferenceLog to track the events that occur). Remove reference you may not require (I use it as some references conflict with DAO blah blah blah).
You should be able to use this to find out if a reference exists or not ( the error message chucked out should tell you that the added reference either is not present, or is already present and being used).
Of course, using Err to determine items is not the best way, but I think the code above offers a solution to both you queries.
A question for you:
Why is it so hard for me (a protestant) to marry my Buddist fiancee in Northern Ireland????
Good luck,
-
Nov 13th, 2000, 11:57 AM
#3
Hyperactive Member
Partial response...
Well, I do not know how to set up your application to check for word but I do believe that you cannot use references for Word 2000 if you also want to use your application on pc's with word97. I could be wrong, but what I would suggest is to use the refrences for Word97 and see how the application works on 2000. I hope this isn't confusing.
Good luck.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Nov 13th, 2000, 01:22 PM
#4
New Member
Word 200/W97 automation
I was able to do this where it did not matter which Word the user had (2000 or 97). The key seemed to be to use the Microsoft Word 9.0 object library, along with 'late' binding. See the following link for explanation.
http://msdn.microsoft.com/library/of...tvariables.htm
When I used the late binding with 9.0 object library, it would run on both Word 97 and Word 2000 environments. When I tried early binding on Word 97 machine, it would GPF. I don't really get it completely, but it did work.
-
Nov 14th, 2000, 12:27 AM
#5
Thread Starter
Hyperactive Member
Kfaymon, vbuser1976, and Gaffer,
Thank you for your quick replies. They have each given me some food for thought and something to start with. Your help is much appreciated.
Rev. Michael L. Burns
-
Nov 15th, 2000, 02:41 AM
#6
As long as you use the WORD 2000 reference you figure it would be backward compatible to cover 97 as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|