"Ronny Sigo" <ro********@skynet.be> wrote in message news:<40**********************@feed0.news.be.easyn et.net>...
Hello all,
I wonder if someone could give me an example of how to assign the text of a
Word document at a given path to a variable ...
x = .......
Any help appreciated ....
Thanks
Ronny
I bastardized Dev's nice code from here...
http://www.mvps.org/access/modules/mdl0043.htm
And here's the bastardized code...
Option Compare Database
Public Function GetDocFileContents(ByVal strPath As String) As String
'This code was originally written by Dev Ashish
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Dim mobjWordApp As Word.Application
Set mobjWordApp = New Word.Application
With mobjWordApp
.Visible = False
.Documents.Add strPath
GetDocFileContents = mobjWordApp.ActiveDocument.Content
.Documents.Close False
End With
mobjWordApp.Quit
Set mobjWordApp = Nothing
End Function
Example Call:
Private Sub Command2_Click()
Me.Text0 = GetDocFileContents("C:\Documents and Settings\Pieter
Linden\Desktop\SomeFile.doc")
End Sub