Macro to combine multiple files into one

Everything related to our flagship word processor.
Post Reply
NisusUser
Posts: 335
Joined: 2011-01-12 05:32:38

Macro to combine multiple files into one

Post by NisusUser »

I would like to find a way to take scores of 2-4 page .rtf files in one folder and combine them into one file in the order of the file names (the filenames start with prefixes such as 01.01, 01.02, 02.01, etc.)

I actually do not need a combined .rtf file. Rather, I need a PDF of the content of all of those .rtf files in order.

(The folder has lots of other files with other suffixes besides .rtf files.)

Is there a quick way to do this?

Thanks!
User avatar
phspaelti
Posts: 1353
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro to combine multiple files into one

Post by phspaelti »

A quick way?
Here is a macro that should work according to your specs, as far as I can make them out.
The pdfs will be saved in the same folder with the name with the prefix removed.
Attachments
Combine Files as PDF.nwm
(7.12 KiB) Downloaded 256 times
philip
NisusUser
Posts: 335
Joined: 2011-01-12 05:32:38

Re: Macro to combine multiple files into one

Post by NisusUser »

phspaelti wrote: 2024-06-09 01:01:51 A quick way?
Here is a macro that should work according to your specs, as far as I can make them out.
The pdfs will be saved in the same folder with the name with the prefix removed.
Thank you, Philip!

The macro required that I select a folder, so I selected the folder where all the files are. But then it gave me this error:
errorwithmacro_w350.png
errorwithmacro_w350.png (39.1 KiB) Viewed 8339 times
I think the macro failed to ask me where to save the file or the file name. I guess it would be good if it would let me choose a file name.

I really appreciate your help with this!
User avatar
phspaelti
Posts: 1353
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro to combine multiple files into one

Post by phspaelti »

If it gives you this error, I must assume that the files are named in a way different from what I took to be your description.
The macro here assumes that your files have names like this:
01.01myfile.rtf
01.02myfile.rtf
02.01myotherfile.rtf
… and so on.
Maybe you should give a more concrete example of how the files are named?
philip
NisusUser
Posts: 335
Joined: 2011-01-12 05:32:38

Re: Macro to combine multiple files into one

Post by NisusUser »

phspaelti wrote: 2024-06-09 04:12:23
Maybe you should give a more concrete example of how the files are named?
I probably misled you somehow.

OK, I'll send a screenshot to you personally, but here are some things I observed:

All files start with

Code: Select all

##.##
Sometimes there are

Code: Select all

##.##a
and

Code: Select all

 ##.##b
Other than the letters after the numbers, in all other cases that I observed, there always is a space after the second set of two numbers (.##space).
Post Reply