Hi All,
I have a table in the database and a Word document saved on the hard disk. I
want to mailmerge the content of the table into the word document, all done
in vba.
Any examples?
I tried this:
DoCmd.SelectOnj ect acTable, "myTable", true
DoCmd.RunComman d acCmdWordMailMe rge
and I get run-time error 2046, "The command or action 'WordMailMerge' isn't
available now.
Regards,
Nicolae 2 3299
Hi again,
I solved this problem. It should be like this:
Private Sub Command0_click( )
Set db = CurrentDb
Set qdf = db.QueryDefs("q ryTemp")
Dim strDocName as String
Set oApp = CreateObject("W ord.Application ")
Set tdf = Nothing
On Error resume next
Set tdf = CurrentDb.Table Defs("tblMailMe rge")
db.TableDefs.De lete "tblMailMer ge"
db.TableDefs.Re fresh
On error go to 0
qdf.SQL = "Select Firstname, Surname into tblMailMerge from tblCustomers"
qdf.Execute dbFailOnError
strDocName = "C:\Docs\mydoc. doc"
oApp.Visible = true
oApp.Applicatio n.Documents.Ope n strDocName
Set oApp = Nothing
End Sub
There might be some bugs (regarding deleting the table tblMailMerge when it
doesn't exist), since I am still developing it, but I solved the initial
error
Regards,
Nicolae
> There might be some bugs (regarding deleting the table tblMailMerge when it doesn't exist), since I am still developing it, but I solved the initial error
So write a function to see if the table exists If not, exit the code. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Shannon Rotz |
last post by:
I have a function in a Microsoft Access module (below) which creates a Word
XP Mailmerge document, drawing the data from Access XP. I can get the
connection to work fine. However, when I create the form letters, the data
from certain merge fields is missing. When I view the data in the MailMerge
Recipients dialog box, the data is not there either - the columns are there,
but the records have blanks where the data in those columns should...
|
by: Ray Todd Jr |
last post by:
I can't get ths code to correctly execute. After I have clicked on a
Access Form, I want the code to open the word document, merge the data,
print the forms and then close the two windows that open of Word.
The Mail Merge takes place, and the sticking point is that I have to
manually close the two Word Windows.
Can someone please tell me what I'm not doing correctly. Below is the
code I am using...
|
by: Dixie |
last post by:
I have a mailmerge that works fine from an MDB database using the
OpenDataSource method to send its data from a query within Access as part of
an automation sequence. Now, if I compile that mdb into an MDE, when I
click a button on the Access form that should produce the mailmerge, the
template opens on the screen with the fields visible, then an error message.
"File in use. <Filename> is locked for editing by 'another user'."
I then...
|
by: RH |
last post by:
Hi,
I'm trying to use mailmerge with Word2003 from an asp.net webpage
I'm using the following code:
Dim W As New Word.Application
Dim D As Word.Document = W.Documents.Open("maindoc.doc")
D.MailMerge.OpenDataSource("address.txt")
D.MailMerge.Destination =
Word.WdMailMergeDestination.wdSendToNewDocument
D.MailMerge.Execute()
|
by: Mikey |
last post by:
Sample VB .NET source code to create mailing labels or customized letters
using MS Word MailMerge
This VB .NET source code will start MS Word and call methods and set
properties in MS Word to execute a MailMerge to create mailing labels or
customized letters.
A label name known to MS Word MailMerge mailing label wizard may be used or
a template file containing the field names Line1 thru Line5 for each record
to be printed. If a...
| |
by: tony.abbitt |
last post by:
I have recently installed Office 2007 (SP1) retaining the previous
installation of Office 2003.
I have converted an Access 2003 database to Access 2007. The database
contains the VBA code 'DoCmd.RunCommand acCmdLinkTables' to initiate
the dialog box to rebuild links to tables held in a back-end Access
database (which has also been converted from Access 2003 to Access
2007).
The code runs without problem in the original Access 2003...
|
by: prakashwadhwani |
last post by:
The Delete Event/Proc & "Save_Fields_In_Form_Header" Event/Proc in
my form were working perfectly.
However, after I added a call to the "Save_Fields_In_Form_Header"
Event/Proc in the "Current" Event of my form, and I now try to Delete
a record, I get ... Run-Time Error 3218 - Could not Update; Currently
Locked. My Access application then effectively freezes forcing me to
shut Access down & re-start.
The record DOES get deleted...
|
by: MLH |
last post by:
The following unexpected error occurred in AppSpecific Module's Sub
Check4PastSaleDates(), line #350 when called from Cron Form:
2046: "The command or action 'SetWarnings' isn't available now."
My error handler captured the problem condition and reported what
you see above. Clicking OK in the msgbox led to other 2046 errors
with other built in VBA commands. What went wrong? I had to close
|
by: dbsog7777 |
last post by:
I was trying to use the sample code below, but I encountered two errors:
Application.DoEvents() and AutoText(entry). I am not sure how to correct the errors. I trying to use the sample code to create a mailmerge routine that accepts data from my SQL database and create a word doc that ce be previewed in the client browser. My OS is XP Pro and I am coding in VB.NET.
Protected Sub CreateWordMailMerge(ByVal strLabelName As String, _
...
|
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...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: 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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |