BookmarkSubscribeRSS Feed
Sami
Obsidian | Level 7

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

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

https://social.msdn.microsoft.com/Forums/en-US/dbfaabd4-1f4c-4281-a3ca-b0ead28ef92d/how-to-insert-a-...

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.

Sami
Obsidian | Level 7
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
Reeza
Super User

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. 

data_null__
Jade | Level 19

@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. 

Sami
Obsidian | Level 7
Hi,

Many thanks. I am starting to look on PROC Document procedures. Is there any concise coding available already, you can suggest or i would start from SAS Help for
PROC Document?
data_null__
Jade | Level 19

There is a book about proc document and you can search at lexjansen.com

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 3386 views
  • 5 likes
  • 5 in conversation