Hi All,
I'm writing a Word Add-in which finds for a string in the document and deletes if there is a line break just before it. Can anyone help me on this
TIA
Pavan
Hi All,
I'm writing a Word Add-in which finds for a string in the document and deletes if there is a line break just before it. Can anyone help me on this
TIA
Pavan
Deleting a line break
Nilmar P. Castro
Hi Kathleen,
I found it http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.word.documentclass.attachedtemplate.aspx
It is in the DocumentClass object. And the method invloved is get_AttachedTemplate(). But this is returning normal.dot and not that template that i've set while doing documents.add()
Regards
Pavan
NicoD
Hey Kathleen,
Thanks for the suggestion. I'll keep that in mind.
As for your suggestion to use WordApplication.Document.AttachedTemplate there is no "Document" in WordAppliction. there is a collection called "Documents" which doesnt have any Attachedtemplate attribute. Any more pointers
BTW im creating using
WordApplication = (Microsoft.Office.Interop.Word.Application)application;
Thanks,
Pavan
Havan
Thanks for that! Can you help me one more thing I'm creating a document using
WordApplication.Documents.Add(
ref template, ref newTemplate, ref documentType, ref visible);to apply a template to the document. Now, when i open the document, i want to get the template name that im using to create the document. How can it be done
if i use WordApplication.templates i get only normal.dot.
TIA
Pavan
lalumbres
Hi Pavan,
This Forum is for VSTO-related questions.
The property is also available inside of Microsoft.Office.Interop.Word.dll. For more information, see http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.word(VS.80).aspx
Hope this helps,
Kathleen McGrath
NgoThaiDuong
hey Kathleen,
Sorry for posting in the wrong forum. I checked the link. It will be of gr8 use to me. Thanks a lot. If possible help me in nailing down the property....like which class it belongs to etc.
Thanks,
Pavan
jho1965dk
Hi Pavan,
Sorry, I was trying to convert from VSTO to whatever you're using. In VSTO you'd use the following code in the ThisDocument class:
' Visual Basic
Me.AttachedTemplate
// #C
this.AttachedTemplate;
You might try: Application.ActiveDocument.AttachedTemplate
or
WordApplication.Documents("Document1").AttachedTemplate
Jordy3077
Hi Pavan,
You should always start a new thread for additional questions as it makes it easier for us to track them.
To answer your question, try WordApplication.Document.AttachedTemplate
Kathleen McGrath
Iain Shanks
Hey Kathleen,
Just FYI the property that u r suggesting is part of microsoft.office.tools.word.dll which comes with VSTO installation. But i'm not using vsto for my addin. Is there any way that i can achieve the same using PIAs (im using PIAs to implement the addin).
Regards,
Pavan
DK Malethia
Hey Kathleen,
I'm sorry to say but there is nothing lke this.AttachedTemplate. The activeDocument object doesnt have any property like AttachedDocument and the Documents collection doesnt seem to an array where i can get the indexed objects. Pls correct me if im wrong and let me know if there are any other pointers.
thanks
Pavan
GProssliner
Hi Pavan,
I'm not sure I'm understanding your question correctly then. When you say you want to get the name of the template, are you saying you want to apply a particular template to the document you're creating If so, you just need to pass the path/name of the template you've created and want to base the document on.
Using get_AttachedTemplate() tells you the name of the template that is attached to your document. If you didn't specify a particular template when you created the doc, Normal.dot will get applied automatically.
Kathleen McGrath
Marco Kotrotsos
Hi,
You can search for a paragraph mark + the string, and replace it with "nothing" or replace it with just an empty paragraph mark if you want to retain it. For example, if the string you're looking for is "find string". Search for "^pfind string".
Kathleen McGrath
http://blogs.msdn.com/vsto2/
Albel
hey Kanthleen,
Thanks a lot.
Actually I've found what exactly the issue is. When I'm creating the document a .doc template is being used in the Add method call and not .dot. And, rightly enough, the method get_AttachedTemplate() to fetch the template name is not returning the document that I've used. I've found that there is no way to find the source template if it is a .doc document, unless you know a better way :-)
Anyways, thank you very much and sorry for confusing you :-)
Regards,
Pavan