We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this questionI cant really seem to find a documentation for word addins in C#. Like to f开发者_运维百科ind out how to insert text I played with intellisense for half and hour to find Application.Selection.Range.InsertAfter();
Is there a documentation to this I'm trying to figure out how to print out formatted text like a link but I'm finding little resources.
Your are not really specifying what you want to do exactly. One of the best starting points into figuring out how to do stuff in office automation is to record a macro and then look at what it generated.
For this question I entered a line of text in a document:
This is a new line of text and this a link
Then I used ctrl+leftarrow 3 times to move the cursor before 'this' and selected the next 4 chars (this). Then I turned the selection into a hyperlink pointing to stackoverflow This is resulting code:
Selection.TypeText Text:="This is a new line of text and this a link"
Selection.MoveLeft Unit:=wdWord, Count:=3
Selection.MoveRight Unit:=wdCharacter, Count:=4, Extend:=wdExtend
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.stackoverflow.com/", SubAddress:="", ScreenTip:="", _
TextToDisplay:="this"
In general it's not that hard to convert this vba stuff to c# and finding the proper methods
There are some resources including code samples etc.:
- http://social.msdn.microsoft.com/Forums/en/vblanguage/thread/b72ba118-b8b1-4758-83c9-4e3618b90b6f
- http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlinks.add.aspx
- http://vsto2007.blogspot.com/2010/05/vsto-word-2007-with-word-addin.html
- http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx
- http://blogs.msdn.com/b/vsto/
- http://msdn.microsoft.com/en-US/office/hh128772.aspx
- http://msdn.microsoft.com/en-us/magazine/cc163292.aspx
- http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.aspx
精彩评论