PC Review


Reply
Thread Tools Rate Thread

best way to merge to word

 
 
=?Utf-8?B?SmFtZXM=?=
Guest
Posts: n/a
 
      7th Feb 2005
Hello,
I have a database and I want to pass some varables to Word to merge. The way
I have it on my machine is I have a Macro and I pass some varables to alter
the Macro.
However, to do this for everyone I would need to install the Macro on every
machine or every document.
What I was wondering is would it be ok to pass all the SQL statement from
the database to word to save setting up the Macro on every machine in the
office? Its not a big statement (just usual mail merge code) but would it
slow the opening of the document up?

Many thanks, James
 
Reply With Quote
 
 
 
 
Naresh Nichani MVP
Guest
Posts: n/a
 
      8th Feb 2005
Hi:

What you could do is put your Word Macro code as part of Access VBA code and
set a refernce to Word. This way you do not need to run a Word Macro.

You could instantiate Word like this --

Dim objWord as Word.Application 'Make a reference to "Microsoft Word Object
Library"
On error resume next
Set objWord = GetObject(,"Word.Application") 'checks for running instance of
Word
if objWord is Nothing then
Set objWord = CreateObject("Word.Application") 'if Word not running
instantiate new copy
objWord.Visible = True 'New instnace of Word must be made visible
end if
On error goto 0

With objWord
'Put your macro code here
'preface word objects in code with objWord here like
objWord.ActiveDocument
End With

Hope this helps.

Regards,

Naresh Nichani
Microsoft Access MVP


"James" <(E-Mail Removed)> wrote in message
news:C3F44381-CDE7-401D-A227-(E-Mail Removed)...
> Hello,
> I have a database and I want to pass some varables to Word to merge. The

way
> I have it on my machine is I have a Macro and I pass some varables to

alter
> the Macro.
> However, to do this for everyone I would need to install the Macro on

every
> machine or every document.
> What I was wondering is would it be ok to pass all the SQL statement from
> the database to word to save setting up the Macro on every machine in the
> office? Its not a big statement (just usual mail merge code) but would it
> slow the opening of the document up?
>
> Many thanks, James



 
Reply With Quote
 
Albert D. Kallal
Guest
Posts: n/a
 
      8th Feb 2005
Perhaps you might give my ms-access to word template system a try.

It enables to you merge the current record you are looking at to a word
template. And, the merge system is NOT hard coded to any field name...so it
will work with your existing applications. You can give the sample a try
here:

http://www.members.shaw.ca/AlbertKal.../msaccess.html
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)
http://www.members.shaw.ca/AlbertKallal


 
Reply With Quote
 
=?Utf-8?B?SmFtZXM=?=
Guest
Posts: n/a
 
      8th Feb 2005
Hi,
Thanks for your reply.

I have done what you say below, but unless I start word first it says
"ActiveX component can't create object".

It works when I open a new document in word and then click the button but it
comes up with the error "Word could not merge the main document with the data
source because the data records were empty or no data records matched your
query options." but then it merges perfectly.

Any suggestions?

"Naresh Nichani MVP" wrote:

> Hi:
>
> What you could do is put your Word Macro code as part of Access VBA code and
> set a refernce to Word. This way you do not need to run a Word Macro.
>
> You could instantiate Word like this --
>
> Dim objWord as Word.Application 'Make a reference to "Microsoft Word Object
> Library"
> On error resume next
> Set objWord = GetObject(,"Word.Application") 'checks for running instance of
> Word
> if objWord is Nothing then
> Set objWord = CreateObject("Word.Application") 'if Word not running
> instantiate new copy
> objWord.Visible = True 'New instnace of Word must be made visible
> end if
> On error goto 0
>
> With objWord
> 'Put your macro code here
> 'preface word objects in code with objWord here like
> objWord.ActiveDocument
> End With
>
> Hope this helps.
>
> Regards,
>
> Naresh Nichani
> Microsoft Access MVP
>
>
> "James" <(E-Mail Removed)> wrote in message
> news:C3F44381-CDE7-401D-A227-(E-Mail Removed)...
> > Hello,
> > I have a database and I want to pass some varables to Word to merge. The

> way
> > I have it on my machine is I have a Macro and I pass some varables to

> alter
> > the Macro.
> > However, to do this for everyone I would need to install the Macro on

> every
> > machine or every document.
> > What I was wondering is would it be ok to pass all the SQL statement from
> > the database to word to save setting up the Macro on every machine in the
> > office? Its not a big statement (just usual mail merge code) but would it
> > slow the opening of the document up?
> >
> > Many thanks, James

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail merge in Word, from Excel, the merge results for a percentag. Conrad Klein Microsoft Word Document Management 1 11th Nov 2009 11:00 PM
Problem with merge data to word document merge field =?Utf-8?B?REI=?= Microsoft Word Document Management 1 14th Sep 2006 11:18 PM
mail merge excludes my headers and critical data in Word merge =?Utf-8?B?Tml4?= Microsoft Excel Misc 0 21st Apr 2006 08:35 PM
Insert Merge Field problem with Word-Mail Merge from Excel documen =?Utf-8?B?QXVndXN0YSBFLg==?= Microsoft Word Document Management 2 20th Jun 2005 10:59 AM
Mail Merge using MS Word and Outlook-Unable to merge Contacts data John O'Grady Microsoft Outlook Contacts 0 24th Jul 2003 12:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:56 AM.