473,493 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Import text to a variable

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
Nov 12 '05 #1
2 1318
"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
Nov 12 '05 #2
Thanks Pieter :)

"Pieter Linden" <pi********@hotmail.com> schreef in bericht
news:bf**************************@posting.google.c om...
"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

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2725
by: Manlio Perillo | last post by:
Hi. I'm a new user of Python but I have noted a little problem. Python is a very good language but it is evolving, in particular its library is evolving. This can be a problem when, ad example,...
4
2176
by: MackS | last post by:
Hi I'm new to Python, I've read the FAQ but still can't get the following simple example working: # file main_mod.py: global_string = 'abc' def main():
1
5882
by: Chris | last post by:
Background: I am using a MS Access 2000 front end with SQL Server 8.0 back end. I have the requirement to import all text files (regardless of filename) from a given folder on the network into a...
0
1590
by: Eric | last post by:
I built a webservice and it needs to pass large amounts of data (50MB+). I built a VB6 test app that uses soap to call the webservice. When the stream of data getting passed back gets larger...
5
1654
by: Tommytrojan | last post by:
Hi, I have been using Python for a while but today I came across a really strange behavior: While poking around in Queue.py due to problems with importing this module from a thread I got an...
4
1761
by: orange | last post by:
I've got a database in .txt file similar to this: BookName;Author;Year;ReviewedBy;Rating;Pages Nemesis;Isaac Asimov;1989;13,31,24;good;110 Sense & Sensibility;Jane Austen;1970;45,32;great;120...
2
12056
by: KingoftheKings | last post by:
I'm new here. I want a help with VB codes that will import text or excel files from a specified directory in to an existing or new Access table. I have written some codes, but when I click the...
3
1987
by: Roy | last post by:
Hi All, I have an A2003 application .Recently we had a request to import data from IDL files and create some reports. Since I have no idea to do that using Access,I used Excel to import data and...
1
10818
by: DThreadgill | last post by:
I have a spreadsheet with about 35 tabs that I need to import into one table in Access. I found this link http://www.thescripts.com/forum/thread650662-import+multiple+tabs.html and changed some...
6
26276
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.