473,473 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sending Text to MS Word

32 New Member
Hi,
Does anyone have any suggestions on how I could send a paragraph of text to a MS Word document? I used a print# statement, but that would only allow text to appear in a .txt file.

Thanks
Feb 2 '07 #1
1 1612
ADezii
8,834 Recognized Expert Expert
Hi,
Does anyone have any suggestions on how I could send a paragraph of text to a MS Word document? I used a print# statement, but that would only allow text to appear in a .txt file.

Thanks
I am assuming that you are sending this paragraph of Text from an Access Text Box (we'll call it [txtWriteToWord] to a Microsoft Word Document. The technology that you want to use is called OLE Automation. It is a very difficult subject but I have condensed it to its simplest form below. The code will transfer the contents of an Access Text Box and insert it into a Microsoft Word Document which would then become visible. It will then be up to you to Save, Print, Format, etc. Here goes...
Expand|Select|Wrap|Line Numbers
  1. 'Declare the variable
  2. Dim WordApp As Object
  3.  
  4. 'Set the variable to run a new instance of Word
  5. Set WordApp = CreateObject("Word.Application")
  6.   'If WordApp does not contain a Word Application Object, get out
  7.   If WordApp Is Nothing Then
  8.     MsgBox "Could not start Word - Application will terminate", vbCritical, "Failure to Initialize"
  9.     Exit Sub
  10.   End If
  11.  
  12. 'Add a New Document
  13. WordApp.Documents.Add
  14.  
  15. 'Add some Text (contents of [txtWriteToWord])
  16. WordApp.Selection.TypeText CStr(Me![txtWriteToWord])
  17.  
  18. 'Make the Word Window visible
  19. WordApp.Visible = True
Feb 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MouseHart | last post by:
I have a small program which lists my music files on my computer, but I can't get it to print exactly the way I want it to. The data is viewed in an MSFlexGrid named "TextGrid" and the following...
0
by: Fabricio de Reuter Sperandio | last post by:
Hi everybody, I did an ASP.NET application to send a fax using the Extended Fax Service COM API. I am running Windows XP. The problem is: When I send Text files, it mens, the FaxDocument.Body...
1
by: Derek | last post by:
I have a simple app that logs details of my customers and the work done for them. It uses a few tables in Access and allows me to keep a basic record of things for my accountant. How can I...
0
by: Andrea | last post by:
Hi I've having a very strange problem using the SendInput API to send text to other applications. I've written the code and it seems to work well. I discovered a strange problem: when I try to...
3
by: David C | last post by:
I have an ASP.Net 2.0 intranet application and would like to be able to send a name and address to an msword content type or something. I want to first just send out the person's name and address...
5
by: =?Utf-8?B?VG9ueSBXaXNzbGVy?= | last post by:
Hello everyone- I am hoping a couple of you will have some ideas on this one... I have a webform created in visual basic 2005. Basically, the webform gather answers to the questions asked on...
2
by: avi1000 | last post by:
Hi I have a Word file with a picture inside that I have inserted and saved as HTML filtered. I'm trying to send the mail so that the Word doc will appear as the body of the mail with the picture...
2
by: Alex Bryan | last post by:
Okay, so what I want to do is connect to dictionary.com and send the website a word, and later receive the definition. But for now, I want to focus on sending the word. A good guy from this mailing...
8
by: Marty | last post by:
I'm having issues sending an email to an "@page.nextel.com" email address. I can send to any other email address fine, but when I try the page.nextel.com it gives me this error: ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
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.