Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Friends,
I have an update to insert the page header in Word document.
I have tried below-mentioned code, but its shows the compile time error.
Any one polease help me.

What I have tried:

C#
string appPath = Path.Combine(Environment.SpecialFolder.ApplicationData.ToString(), @"Microsoft\Document Building Blocks\1033\14\Built-In Building Blocks.dotx");
                {
                    doc.Application.Templates.Application.Templates[appPath].BuildingBlockEntries(" Blank").Insert( Where: doc.Content, RichText: true);
                }
Posted
Updated 13-Jan-19 22:44pm
Comments
Richard Deeming 18-Jan-19 12:33pm    
When you get an error, you need to show us the full details of the error. You can't just say "it shows a compile time error" and expect us to know what the problem is.

Also, the first line of your code block won't do what you expect it to do. Environment.SpecialFolder.ApplicationData.ToString() will always return the literal string "ApplicationData". If you want to get the path to that folder, you need to call Environment.GetFolderPath[^] passing in the SpecialFolder you want to find.
string appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Document Building Blocks\1033\14\Built-In Building Blocks.dotx");

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900