473,837 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to send the current record to Word 2000 with automation

Hi,
I made an Access 2002 Database and wanted to automate it to sent the
current record to Word 2002. So readed the article "How to send the
current record to Word 2000 with automation" I tried to do this with my
db.
Here is my code:

Private Sub MergeButton_Cli ck()
On Error GoTo MergeButton_Err

Dim objWord As Word.Applicatio n

'Start Microsoft Word 97.
Set objWord = CreateObject("W ord.Application ")

With objWord
'Make the application visible.
.Visible = True

'Open the document.
.Documents.Open ("D:\Aullo\Récl amation_Test.do c")

'Move to each bookmark and insert text from the form.

.ActiveDocument .Bookmarks("Mat ricule_E").Sele ct
.Selection.Text = (CStr(Forms!Réc lmation!Matricu le_E))
.ActiveDocument .Bookmarks("Mat ricule_D").Sele ct
.Selection.Text = (CStr(Forms!Réc lamation!Matric ule_D))

End With

'Print the document in the foreground so Microsoft Word will not
close
'until the document finishes printing.
objWord.ActiveD ocument.PrintOu t Background:=Fal se

'Close the document without saving changes.
objWord.ActiveD ocument.Close SaveChanges:=wd DoNotSaveChange s

'Quit Microsoft Word and release the object variable.
objWord.Quit
Set objWord = Nothing
Exit Sub

MergeButton_Err :
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.Number = 94 Then
objWord.Selecti on.Text = ""
Resume Next
End If

Exit Sub
End Sub

Here is now my problem: It opens my word document but does not insert
any objets. I don't understand why??
Can anybody help my?

Nov 13 '05 #1
1 2153

The code you posted is fairly common, bases on (or perhaps exactly) the
code from the Access 97 Developer's Handbook
(http://www.developershandbook.com/) even if you didn't get it from
there.

The code does not actually "fill out" a word form, what it does is
_replace_ the form's bookmarks with the text from your application.

This means the code will fail if either your form doesn't have
bookmarks in it (most likely case) or you're using it to fill out a
previously filled out form.

moelleni wrote:
Hi,
I made an Access 2002 Database and wanted to automate it to sent the
current record to Word 2002. So readed the article "How to send the
current record to Word 2000 with automation" I tried to do this with my
db.
Here is my code:

Private Sub MergeButton_Cli ck()
On Error GoTo MergeButton_Err
Dim objWord As Word.Applicatio n
'Start Microsoft Word 97.
Set objWord = CreateObject("W ord.Application ")
With objWord
'Make the application visible.
.Visible = True
'Open the document.
.Documents.Open ("D:\Aullo\Récl amation_Test.do c")
'Move to each bookmark and insert text from the form.
.ActiveDocument .Bookmarks("Mat ricule_E").Sele ct
.Selection.Text = (CStr(Forms!Réc lmation!Matricu le_E))
.ActiveDocument .Bookmarks("Mat ricule_D").Sele ct
.Selection.Text = (CStr(Forms!Réc lamation!Matric ule_D))
End With <snip> Here is now my problem: It opens my word document but does not insert
any objets. I don't understand why??
Can anybody help my?


Nov 13 '05 #2

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

Similar topics

12
5541
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000 and office XP components installed. ie I have word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to word 2k automation yet I get the error "Automation Error" "ClassFactory cannot supply requested class" when on late binding try...
0
1347
by: dixie | last post by:
I have an application which does a lot of reports (letters) by automation with Word. The mail merge main document is a Word template and I transfer a text file out to a prenamed filename to act as the data source, then open a ..doc file from the template. The template has the name of the data file as its data source. All worked fine in Word 2000 and Word 2002, but all of a sudden, with Word 2003, I get an error message that says "This...
2
2617
by: kids | last post by:
Does anybody know any reason which could cause Ms. word automation to crash? I try to call word automation to open a document and use find and replace function. For some reason it works but I don't know why it crash some time.
1
1277
by: Jack Jiao | last post by:
Hi, I am using MS Word inside C# application. The application is using impersonation as Administrator. The application works fine for a few days then suddenly I started to get "access is denied" message everytime I instantiate instantiate MS word like "oWordApp = new Word.ApplicationClass();" Not just this application, any application uses word automation now don't work any more. There's nothing I can do to make the error go away. ...
2
3687
by: Andrew Cranwell | last post by:
Hi, Please redirect me if I am in the wrong group for this question... this is my first post to this group, so I hope it is clear! I am working on an automation project in VB.NET and have to interact with Word 2000 SP-3 to find and replace text within a word document. Unfortunately, development (not created by me!) occured with Word 2000 SR-1 and on ugrading the references and version to SP-3, some of the code inexplicably stopped...
1
2064
by: John | last post by:
Hi, I have a question to ask in how to send e-mail through a program written by VB.Net with the help of MS Word and Outlook? The platform will be like this: OS - Win 2K Pro Office 2000 with MS Word and Outlook DB - SQL Server
4
3697
by: JensB | last post by:
I have VB.Net VS2005 App which creates MS Word documents. Clients are using Word 2000 and Word2003. Project refers to MS Word 9.0 Object library, declaring Word as an object. On the Word 2000 machines this works fast and nice, but on the Word 2003 machines it takes 5-10 times longer. Is there a way to make Word 2003 clients to work faster? Recently a warning message, showed up in the error list: "There are updated custom wrappers...
1
1304
by: ljh | last post by:
I want to develop an application that can watch for and monitor any instance of Word 2000/2003. I need to be able to write an add-in menu for Word 2000/2003 and capture all keystrokes and mouse events done in Word also, for a training application. I am searching for all of the code that I can get my grubby little hands on that shows key and mouse capturing with .Net 2005 and code that shows monitoring and controll of Word, Outlook and...
5
3496
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record the cursor was on in the datasheet at the time I executed the macro. So, the questions are: 1) In the macro, how to I get my hands on the record key or record data of the record the cursor was on in the datasheet at the time I executed the...
0
9843
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9683
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10577
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10275
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9407
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7811
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5851
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4476
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 we have to send another system

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.