VBA Mail Merge with specific value of row2019 Community Moderator ElectionIs there a way to crack the password on an Excel VBA Project?Where does VBA Debug.Print log to?Trouble with Mail Merge IF field and VBAHow to avoid using Select in Excel VBAExcel macro to Word mail merge is trying to merge ALL rows in the columnHow can I make Mail Merge display different, or remove, TEXT depending on the merged data?Mail Merge with multiple child recordsWord Master-Detail Mail MergeSorting and filtering a Word Mail Merge with VBAmail merge excel vba

What is better: yes / no radio, or simple checkbox?

After `ssh` without `-X` to a machine, is it possible to change `$DISPLAY` to make it work like `ssh -X`?

I can't die. Who am I?

NASA's RS-25 Engines

Signed and unsigned numbers

Which classes are needed to have access to every spell in the PHB?

How do electrons receive energy when a body is heated?

Is it possible that a question has only two answers?

Would an aboleth's Phantasmal Force lair action be affected by Counterspell, Dispel Magic, and/or Slow?

What is the generally accepted pronunciation of “topoi”?

Windows Server Data Center Edition - Unlimited Virtual Machines

When Schnorr signatures are part of Bitcoin will it be possible validate each block with only one signature validation?

Why restrict private health insurance?

What ability score modifier does a javelin's damage use?

Doubts in understanding some concepts of potential energy

Why does cron require MTA for logging?

What materials can be used to make a humanoid skin warm?

Does an unused member variable take up memory?

Possible to detect presence of nuclear bomb?

Can the alpha, lambda values of a glmnet object output determine whether ridge or Lasso?

Finitely many repeated replacements

Gaining more land

PTIJ: Why does only a Shor Tam ask at the Seder, and not a Shor Mu'ad?

Expressing logarithmic equations without logs



VBA Mail Merge with specific value of row



2019 Community Moderator ElectionIs there a way to crack the password on an Excel VBA Project?Where does VBA Debug.Print log to?Trouble with Mail Merge IF field and VBAHow to avoid using Select in Excel VBAExcel macro to Word mail merge is trying to merge ALL rows in the columnHow can I make Mail Merge display different, or remove, TEXT depending on the merged data?Mail Merge with multiple child recordsWord Master-Detail Mail MergeSorting and filtering a Word Mail Merge with VBAmail merge excel vba










0















I am trying to create a bulkletter based on an Excel file with the following basic structure:




ID Name Street Info... 

12 John XXX YYY

13 Mark YYY ZZZ

14 Hunter OOO NNN



ID, Name , Street and Info serve as columns here.



To create and export the complete letter in PDF I declare a constant StartWith and EndWith that take on the value of the corresponding row. The basic VBA Code looks like this (this doesnt include al the export steps, just the necessary parts for the starting and end values):



startWith = 1 
endWith = 3
counter = startWith


With ActiveDocument.MailMerge
.DataSource.ActiveRecord = startWith
Do
With .DataSource
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
End With
.Execute Pause:=False

ActiveDocument.SaveAs FileName:=sLetter, FileFormat:=wdFormatPDF
ActiveDocument.Close False

If .DataSource.ActiveRecord < .DataSource.RecordCount And counter <= endWith Then
.DataSource.ActiveRecord = wdNextRecord
counter = counter + 1
Else
Exit Do
End If
Loop
End With

If DataSource.ActiveRecord < DataSource.RecordCount Then
DataSource.ActiveRecord = wdNextRecord

Else

End If


Instead of declaring a constand StartWith and EndWith I would like to set the value of StartWith and EndWith to a certain value of the ID column, so that I can start at ID 13 and end at 15, f.e. instead of defining StartWith as the corresponding row number. Is there a way to implement this in VBA?



Thank you for your help, I greatly appreciate it!










share|improve this question









New contributor




Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Would it work for you to query the mail merge data so that it only contains the records you're interested in? Then the code would loop all the records - no need for StartWith and EndWith. In Word, in the Mailings tab, choose Edit Recipient list, then click the "Filter" link. In the Filter and Sort dialog box you can the set the ID field >= 13 and Id field <= 15. If this works for you, in the VBA Editor's immediate window type: ActiveDocument.MailMerge.DataSource.QueryString to get the query syntax - it will be something like SELECT * FROM Contacts WHERE ID <= '13' AND ID >= '15'.

    – Cindy Meister
    Mar 6 at 20:24















0















I am trying to create a bulkletter based on an Excel file with the following basic structure:




ID Name Street Info... 

12 John XXX YYY

13 Mark YYY ZZZ

14 Hunter OOO NNN



ID, Name , Street and Info serve as columns here.



To create and export the complete letter in PDF I declare a constant StartWith and EndWith that take on the value of the corresponding row. The basic VBA Code looks like this (this doesnt include al the export steps, just the necessary parts for the starting and end values):



startWith = 1 
endWith = 3
counter = startWith


With ActiveDocument.MailMerge
.DataSource.ActiveRecord = startWith
Do
With .DataSource
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
End With
.Execute Pause:=False

ActiveDocument.SaveAs FileName:=sLetter, FileFormat:=wdFormatPDF
ActiveDocument.Close False

If .DataSource.ActiveRecord < .DataSource.RecordCount And counter <= endWith Then
.DataSource.ActiveRecord = wdNextRecord
counter = counter + 1
Else
Exit Do
End If
Loop
End With

If DataSource.ActiveRecord < DataSource.RecordCount Then
DataSource.ActiveRecord = wdNextRecord

Else

End If


Instead of declaring a constand StartWith and EndWith I would like to set the value of StartWith and EndWith to a certain value of the ID column, so that I can start at ID 13 and end at 15, f.e. instead of defining StartWith as the corresponding row number. Is there a way to implement this in VBA?



Thank you for your help, I greatly appreciate it!










share|improve this question









New contributor




Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Would it work for you to query the mail merge data so that it only contains the records you're interested in? Then the code would loop all the records - no need for StartWith and EndWith. In Word, in the Mailings tab, choose Edit Recipient list, then click the "Filter" link. In the Filter and Sort dialog box you can the set the ID field >= 13 and Id field <= 15. If this works for you, in the VBA Editor's immediate window type: ActiveDocument.MailMerge.DataSource.QueryString to get the query syntax - it will be something like SELECT * FROM Contacts WHERE ID <= '13' AND ID >= '15'.

    – Cindy Meister
    Mar 6 at 20:24













0












0








0








I am trying to create a bulkletter based on an Excel file with the following basic structure:




ID Name Street Info... 

12 John XXX YYY

13 Mark YYY ZZZ

14 Hunter OOO NNN



ID, Name , Street and Info serve as columns here.



To create and export the complete letter in PDF I declare a constant StartWith and EndWith that take on the value of the corresponding row. The basic VBA Code looks like this (this doesnt include al the export steps, just the necessary parts for the starting and end values):



startWith = 1 
endWith = 3
counter = startWith


With ActiveDocument.MailMerge
.DataSource.ActiveRecord = startWith
Do
With .DataSource
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
End With
.Execute Pause:=False

ActiveDocument.SaveAs FileName:=sLetter, FileFormat:=wdFormatPDF
ActiveDocument.Close False

If .DataSource.ActiveRecord < .DataSource.RecordCount And counter <= endWith Then
.DataSource.ActiveRecord = wdNextRecord
counter = counter + 1
Else
Exit Do
End If
Loop
End With

If DataSource.ActiveRecord < DataSource.RecordCount Then
DataSource.ActiveRecord = wdNextRecord

Else

End If


Instead of declaring a constand StartWith and EndWith I would like to set the value of StartWith and EndWith to a certain value of the ID column, so that I can start at ID 13 and end at 15, f.e. instead of defining StartWith as the corresponding row number. Is there a way to implement this in VBA?



Thank you for your help, I greatly appreciate it!










share|improve this question









New contributor




Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am trying to create a bulkletter based on an Excel file with the following basic structure:




ID Name Street Info... 

12 John XXX YYY

13 Mark YYY ZZZ

14 Hunter OOO NNN



ID, Name , Street and Info serve as columns here.



To create and export the complete letter in PDF I declare a constant StartWith and EndWith that take on the value of the corresponding row. The basic VBA Code looks like this (this doesnt include al the export steps, just the necessary parts for the starting and end values):



startWith = 1 
endWith = 3
counter = startWith


With ActiveDocument.MailMerge
.DataSource.ActiveRecord = startWith
Do
With .DataSource
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
End With
.Execute Pause:=False

ActiveDocument.SaveAs FileName:=sLetter, FileFormat:=wdFormatPDF
ActiveDocument.Close False

If .DataSource.ActiveRecord < .DataSource.RecordCount And counter <= endWith Then
.DataSource.ActiveRecord = wdNextRecord
counter = counter + 1
Else
Exit Do
End If
Loop
End With

If DataSource.ActiveRecord < DataSource.RecordCount Then
DataSource.ActiveRecord = wdNextRecord

Else

End If


Instead of declaring a constand StartWith and EndWith I would like to set the value of StartWith and EndWith to a certain value of the ID column, so that I can start at ID 13 and end at 15, f.e. instead of defining StartWith as the corresponding row number. Is there a way to implement this in VBA?



Thank you for your help, I greatly appreciate it!







excel vba ms-word ms-office mailmerge






share|improve this question









New contributor




Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Mar 6 at 14:47









pascal sanchez

855218




855218






New contributor




Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 6 at 14:27









Wannabe-economistWannabe-economist

11




11




New contributor




Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Wannabe-economist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Would it work for you to query the mail merge data so that it only contains the records you're interested in? Then the code would loop all the records - no need for StartWith and EndWith. In Word, in the Mailings tab, choose Edit Recipient list, then click the "Filter" link. In the Filter and Sort dialog box you can the set the ID field >= 13 and Id field <= 15. If this works for you, in the VBA Editor's immediate window type: ActiveDocument.MailMerge.DataSource.QueryString to get the query syntax - it will be something like SELECT * FROM Contacts WHERE ID <= '13' AND ID >= '15'.

    – Cindy Meister
    Mar 6 at 20:24

















  • Would it work for you to query the mail merge data so that it only contains the records you're interested in? Then the code would loop all the records - no need for StartWith and EndWith. In Word, in the Mailings tab, choose Edit Recipient list, then click the "Filter" link. In the Filter and Sort dialog box you can the set the ID field >= 13 and Id field <= 15. If this works for you, in the VBA Editor's immediate window type: ActiveDocument.MailMerge.DataSource.QueryString to get the query syntax - it will be something like SELECT * FROM Contacts WHERE ID <= '13' AND ID >= '15'.

    – Cindy Meister
    Mar 6 at 20:24
















Would it work for you to query the mail merge data so that it only contains the records you're interested in? Then the code would loop all the records - no need for StartWith and EndWith. In Word, in the Mailings tab, choose Edit Recipient list, then click the "Filter" link. In the Filter and Sort dialog box you can the set the ID field >= 13 and Id field <= 15. If this works for you, in the VBA Editor's immediate window type: ActiveDocument.MailMerge.DataSource.QueryString to get the query syntax - it will be something like SELECT * FROM Contacts WHERE ID <= '13' AND ID >= '15'.

– Cindy Meister
Mar 6 at 20:24





Would it work for you to query the mail merge data so that it only contains the records you're interested in? Then the code would loop all the records - no need for StartWith and EndWith. In Word, in the Mailings tab, choose Edit Recipient list, then click the "Filter" link. In the Filter and Sort dialog box you can the set the ID field >= 13 and Id field <= 15. If this works for you, in the VBA Editor's immediate window type: ActiveDocument.MailMerge.DataSource.QueryString to get the query syntax - it will be something like SELECT * FROM Contacts WHERE ID <= '13' AND ID >= '15'.

– Cindy Meister
Mar 6 at 20:24












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Wannabe-economist is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025436%2fvba-mail-merge-with-specific-value-of-row%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Wannabe-economist is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Wannabe-economist is a new contributor. Be nice, and check out our Code of Conduct.












Wannabe-economist is a new contributor. Be nice, and check out our Code of Conduct.











Wannabe-economist is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025436%2fvba-mail-merge-with-specific-value-of-row%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко