View Single Post
 
Old 10-07-2021, 03:22 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,978
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I don't like using bookmarks to transfer content or data. Looking at your code for instance, you keep moving the End_of_Snippet so you wouldn't be able to run the macro a second time without removing the additions the first time.

I tend to use Content Controls instead and find them a bit more flexible. For instance, if you have multiple snippets to transfer from each target doc then you could use matching tag and title properties of CCs in both source and target docs to marry content.
Code:
Dim aCC as ContentControl, aCC2 as ContentControl, sTag as String, sTitle as String
  For Each aCC In aDocSrc.SelectContentControlsByTag(sTag)
    sTitle = aCC.Title
    For Each aCC2 In aDocTgt.SelectContentControlsByTitle(sTitle)
      aCC2.Range.FormattedText = aCC.Range.FormattedText  'or add to end if you prefer
    Next
  Next aCC
Sorting the files is a bit involved. You could either save the list to an array (then use a bubblesort function to order) or to a recordset and sort that. I suspect the mfd.SelectedItems is already an array so that makes it probably the most likely contender.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote