HI,
At SAS Community, there was solution for Combining RTF Documents into one document. http://www.lexjansen.com/pharmasug/2010/po/po05.pdf
I have used this Code, and successfully combine RTFs into a single file. However, now facing problem on creating TOC for SIngle file on which, all the Titles from RTFs' files will presented as TOCs.
Can anyone please help me?
Sami
Yes, I have looked at doing this some years back. It is really not simple and to my mind a bit of a waste of time. You would find it simpler to complile the RTF's in Word and use a bit of VBA scripting to create the TOC (if you really need to do it this way). We create combined PDF's of our output RTF files, and assign bookmakrs to each section - so no TOC. The reason being, as soon as your document is comibined with another then the TOC becomes more of an inconvienience.
There are plenty of VBA examples out there:
https://msdn.microsoft.com/en-us/library/office/ff835785.aspx
Etc. Then just save the file as RTF to get a final complete RTF with all the bits. Do note, you could also use this macro to load and combine all the RTF files in the first place.
Word decides TITLES based on the styles. Make sure the TITLE is set as Header 1 in Word and then it will be automatic.
Wothout knowing the rest of the process I'm not sure we can offer options on how to automate the process. If it's one for each file, maybe you can adapt a section of your code to track this and create a single page with the ToC that gets merged in separately.
@Sami wrote:
Hi,
Thanks for your suggestion. Using TOC in that case becoming manual and problem is i am not familiar with VBA code. Still looking any solution programmatically using SAS
If your could back up one step from RTF and use PROC DOCUMENT you can replay stored documents into a combined RTF and create a TOC, no WORD or VBA involved. My application which is similar to this is in PHARMA to produce BIMO listings that are bookmarked PDF.
You'll have to learn PROC DOCUMENT but that is easier than fiddling with raw RTF. Using PROC DOCUMENT keeps your application in SAS and you can use SAS to generate the PROC DOCUMENT statements (MAKE DIR SETLABEL LINK etc.) you will need to create the new combined document.
There is a book about proc document and you can search at lexjansen.com
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.