N
NickP
Hi there,
I'm adding a SmartTag via code, but unfortunately it appears that the
system has a few issues as I end up with 1 tag, but it keeps increasing in
size and the verbs double up...
Here is a snipette of code,
-----
'//Remove selection
Call addin.Application.Selection.SetRange(addin.Application.Selection.End,
addin.Application.Selection.End)
'//Add Text
Dim pStrText As String = "MyTag"
Call addin.Application.Selection.InsertAfter(pStrText)
'//Get start and end pos of new insertion and create a new range object from
it
Dim pRanSelection As Microsoft.Office.Interop.Word.Range =
addin.Application.Selection.Range
Dim pIntStartPos As Integer = pRanSelection.Start
Dim pIntEndPos As Integer = pRanSelection.End
Dim pRanTag As Microsoft.Office.Interop.Word.Range =
addin.Application.ActiveDocument.Range(CObj(pIntStartPos), CObj(pIntEndPos))
'//Add the smart tag
Dim pSTgTag As Microsoft.Office.Interop.Word.SmartTag =
Globals.EquilibriumWord07.Application.ActiveDocument.SmartTags.Add("urn:altavente-com#EquilibriumO07ExSmartTag",
CObj(pRanTag))
Call pSTgTag.Properties.Add("DataType", "IF_TYPE_SINGLE_WD")
'//Execute the first verb
Call pSTgTag.SmartTagActions(1).Execute()
'//Remove seleciton
Call addin.Application.Selection.SetRange(addin.Application.Selection.End,
addin.Application.Selection.End)
-----
It appears fine, but if I press Return or Space, the smart tag extends
with the cursor. I thought maybe that this was because I was originally
passing the selection range object, and thought maybe that as the values
change when you select something else, it may have been keeping the same
object instance, but alas this is not the case.
As for my Tags verbs appear twice, one after each other...
Verb 1 text
Verb 2 text
Verb 1 text
Verb 2 text
It seems quite flakey at the moment. Anyone got any suggestions?
TIA.
Nick.
I'm adding a SmartTag via code, but unfortunately it appears that the
system has a few issues as I end up with 1 tag, but it keeps increasing in
size and the verbs double up...
Here is a snipette of code,
-----
'//Remove selection
Call addin.Application.Selection.SetRange(addin.Application.Selection.End,
addin.Application.Selection.End)
'//Add Text
Dim pStrText As String = "MyTag"
Call addin.Application.Selection.InsertAfter(pStrText)
'//Get start and end pos of new insertion and create a new range object from
it
Dim pRanSelection As Microsoft.Office.Interop.Word.Range =
addin.Application.Selection.Range
Dim pIntStartPos As Integer = pRanSelection.Start
Dim pIntEndPos As Integer = pRanSelection.End
Dim pRanTag As Microsoft.Office.Interop.Word.Range =
addin.Application.ActiveDocument.Range(CObj(pIntStartPos), CObj(pIntEndPos))
'//Add the smart tag
Dim pSTgTag As Microsoft.Office.Interop.Word.SmartTag =
Globals.EquilibriumWord07.Application.ActiveDocument.SmartTags.Add("urn:altavente-com#EquilibriumO07ExSmartTag",
CObj(pRanTag))
Call pSTgTag.Properties.Add("DataType", "IF_TYPE_SINGLE_WD")
'//Execute the first verb
Call pSTgTag.SmartTagActions(1).Execute()
'//Remove seleciton
Call addin.Application.Selection.SetRange(addin.Application.Selection.End,
addin.Application.Selection.End)
-----
It appears fine, but if I press Return or Space, the smart tag extends
with the cursor. I thought maybe that this was because I was originally
passing the selection range object, and thought maybe that as the values
change when you select something else, it may have been keeping the same
object instance, but alas this is not the case.
As for my Tags verbs appear twice, one after each other...
Verb 1 text
Verb 2 text
Verb 1 text
Verb 2 text
It seems quite flakey at the moment. Anyone got any suggestions?
TIA.
Nick.