Go Back   Access World Forums > Apps and Windows > Word

 
Reply
 
Thread Tools Rating: Thread Rating: 114 votes, 5.00 average. Display Modes
Old 02-01-2011, 03:47 PM   #16
RossWindows
Que?
 
RossWindows's Avatar
 
Join Date: Feb 2008
Location: California
Posts: 410
Thanks: 0
Thanked 6 Times in 5 Posts
RossWindows is on a distinguished road
Re: Mail Merge - Dynamic subject line?

So you already tried this? Does the wizard appear at this point?
Quote:
Originally Posted by hutchinsfairy View Post
...
Paste the entire code into the blank pane that opens and save. Close the Visual Basic Editor and the Word document and re-open the word document.

Run the merge from the wizard that should appear to the right of the document...
Also like hutchinsfairy pointed out, this only works from the task pane; not the toolbar button. The ribbon in 2007 might be in the same boat so-to-speak, as the equivalent toolbar button, so I would definitely try and find a computer with 2003 and see if it works there; at least then you might narrow down the problem.

(or post it here if you're able to; I have 2003 and would be willing to test it for you)

__________________
"I prefer thinking about what's inside the box." - Me

Post hoc ergo propter hoc.

- Access '97, 2003, 2007, SQL Server 2008
RossWindows is offline   Reply With Quote
Old 02-01-2011, 03:57 PM   #17
mikeo1313
Newly Registered User
 
Join Date: May 2010
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
mikeo1313 is on a distinguished road
Re: Mail Merge - Dynamic subject line?

I've been using the ribbon button and only have a 2007 & 2010 office install on other computers. How would I use the toolbar in word 2007 as I've been usng the ribbon???
mikeo1313 is offline   Reply With Quote
Old 02-01-2011, 10:23 PM   #18
mikeo1313
Newly Registered User
 
Join Date: May 2010
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
mikeo1313 is on a distinguished road
Re: Mail Merge - Dynamic subject line?

ended up working, I had to "compile" project. great post!

mikeo1313 is offline   Reply With Quote
Old 10-24-2011, 05:40 PM   #19
Gr8Veto
Newly Registered User
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Gr8Veto is on a distinguished road
Re: Mail Merge - Dynamic subject line?

When I tried to "compile" the project it didn't like something about the ".ShowWizard". The error I got was "Method or data member not found".

I am using Word 2011 for Mac.

Any ideas...?
Gr8Veto is offline   Reply With Quote
Old 05-25-2012, 10:46 AM   #20
AnnSki26
Newly Registered User
 
Join Date: May 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
AnnSki26 is on a distinguished road
Re: Mail Merge - Dynamic subject line?

Thank you so much for this code. It solved my problem perfectly!
AnnSki26 is offline   Reply With Quote
Old 03-29-2013, 06:03 PM   #21
supabribri
Newly Registered User
 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
supabribri is on a distinguished road
Re: Mail Merge - Dynamic subject line?

sorry to sound like a fool.. but where in the code do I put the "<subject>" or excel data field?
supabribri is offline   Reply With Quote
Old 04-14-2013, 10:58 AM   #22
RossWindows
Que?
 
RossWindows's Avatar
 
Join Date: Feb 2008
Location: California
Posts: 410
Thanks: 0
Thanked 6 Times in 5 Posts
RossWindows is on a distinguished road
Re: Mail Merge - Dynamic subject line?

In Word, the "<<subject>>" data field is added directly on your word document, not in the code.
It's been a long time since I used merge but if you still need help, just let us know.

__________________
"I prefer thinking about what's inside the box." - Me

Post hoc ergo propter hoc.

- Access '97, 2003, 2007, SQL Server 2008
RossWindows is offline   Reply With Quote
Old 08-08-2013, 12:27 AM   #23
tnm
Newly Registered User
 
Join Date: Aug 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tnm is on a distinguished road
Re: Mail Merge - Dynamic subject line?

Hi all,

Please help I'm tearing my hair out here!

I've successfully used the above code in the past using Word & Outlook 2007. I've no idea why but I can no longer get it to work correctly.

If I paste the code into a Module and try to compile it objects to the first line "Dim WithEvents wdapp As Application" and errors - "Only valid in object module"

I have also tried pasting the code into a class module and it does compile OK. However when I try processing the merge with the relevant fields in chevrons it does not merge the subject line.

I've no idea how I got it working last time I used it and why I can't this time. I'd be very grateful for any advice. Please bear in mind I have no experience programming in VBA but as I'm using pre-written code this shouldn't matter!

Many thanks for any input
Tom
tnm is offline   Reply With Quote
Old 08-08-2013, 12:39 AM   #24
RossWindows
Que?
 
RossWindows's Avatar
 
Join Date: Feb 2008
Location: California
Posts: 410
Thanks: 0
Thanked 6 Times in 5 Posts
RossWindows is on a distinguished road
Re: Mail Merge - Dynamic subject line?

Hmm, interesting problem tnm. First I want to clarify; what version of Word are you using now? (your initial post is a little ambiguous). Secondly (after thinking about it for a minute), it looks a lot like a missing library reference, but honestly it's been a while.

Before you get too far, remember; as stated in previous posts, certain newer versions of Word that utilize the Ribbon Bar can encounter problems when used with the aforementioned code. (I don't know if that's relevant here; just going off what I see at a glance).
__________________
"I prefer thinking about what's inside the box." - Me

Post hoc ergo propter hoc.

- Access '97, 2003, 2007, SQL Server 2008

Last edited by RossWindows; 08-08-2013 at 12:50 AM. Reason: more brain
RossWindows is offline   Reply With Quote
Old 08-08-2013, 12:43 AM   #25
tnm
Newly Registered User
 
Join Date: Aug 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tnm is on a distinguished road
Re: Mail Merge - Dynamic subject line?

Hi Ross,

Thanks for the quick response. I'm using Office 2007, same as last time I sucessfully used the code. Working on a different machine but the Office installation is standard throghout our network.

I do start the merge from the ribbon as I don't think Word 2007 includes the task pane that was present in 2003.

I've tried adding the code to both the document I'm working on and to Normal without success.

I'd appreciate any advice.

Regards
Tom
tnm is offline   Reply With Quote
Old 08-08-2013, 12:53 AM   #26
RossWindows
Que?
 
RossWindows's Avatar
 
Join Date: Feb 2008
Location: California
Posts: 410
Thanks: 0
Thanked 6 Times in 5 Posts
RossWindows is on a distinguished road
Re: Mail Merge - Dynamic subject line?

Hi tnm, sorry, I've edited my last post. I may have edited it while you were posting your last response... just posting this to prompt any automated notifications for you.
__________________
"I prefer thinking about what's inside the box." - Me

Post hoc ergo propter hoc.

- Access '97, 2003, 2007, SQL Server 2008
RossWindows is offline   Reply With Quote
Old 08-21-2013, 06:14 PM   #27
KiwiRyu
Newly Registered User
 
Join Date: Aug 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
KiwiRyu is on a distinguished road
Re: Mail Merge - Dynamic subject line?

Hi Ross,

I'm also trying to use this piece of VBA, but dont quite understand how to point it at the column I'm looking for. I'm using Office 2007. My Data Source is Excel. The subject line I want to use is found in a column named "mysubjectfield". I added that as a merge field onto the word doc but that did not change the subject line. I suspect I've missed something here, should I rename the excel column which contains the subject lines?

Quote:
Originally Posted by RossWindows View Post
In Word, the "<<subject>>" data field is added directly on your word document, not in the code.
It's been a long time since I used merge but if you still need help, just let us know.
KiwiRyu is offline   Reply With Quote
Old 10-07-2013, 05:26 AM   #28
MHutcheson
Newly Registered User
 
Join Date: Sep 2013
Location: N/A
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
MHutcheson is on a distinguished road
Re: Mail Merge - Dynamic subject line?

I have a Word 2010 document linked to an Access 2010 data source. When a user clicks a button in Access, the Word document loads and performs a email merge using the below VBA code:

Private Sub Document_Open()
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
.MailSubject = ActiveDocument.MailMerge.DataSource.DataFields("Re turn_code").Value
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord

End With
.Execute Pause:=False
End With
End Sub

However, as the .mailsubject part is not in the loop it is only retrieving the first Return Code. I have tried to integrate in the loop to no avail. Also, how do I add static text to the Subject, I need something like "Your Return Code" + "Return Code"

Thank you for any help.

Regards,

Michael
MHutcheson is offline   Reply With Quote
Old 10-23-2013, 06:43 AM   #29
MHutcheson
Newly Registered User
 
Join Date: Sep 2013
Location: N/A
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
MHutcheson is on a distinguished road
Re: Mail Merge - Dynamic subject line?

Thanks for getting back to me. I managed to resolve this though.
MHutcheson is offline   Reply With Quote
Old 02-09-2014, 05:59 AM   #30
motlaghjs
Newly Registered User
 
Join Date: Feb 2014
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
motlaghjs is on a distinguished road
Re: Mail Merge - Dynamic subject line?

The VBA code works great! Thanks.

The other function I'm looking for is to be able to cc and bcc other contacts from the merge. Could someone provide the VBA code to do that and mention where in it needs to go since I'm using the code for dynamic subject line as well.

Thanks!

motlaghjs is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced Mail Merge Question adam.greer General 7 02-09-2007 02:43 AM
Mail merge query results garywood84 Queries 16 09-23-2006 11:20 AM
Mail Merge from an SQL server database tigernick SQL Server 2 09-04-2006 11:51 PM
[SOLVED] problems with mail merge and combo boxes discman9 Queries 5 11-04-2003 12:31 PM
Mail Merge from a Query expublish Forms 1 03-07-2002 08:36 AM




All times are GMT -8. The time now is 04:34 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World