TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chetan Allipur
NA
541
166.2k
How to Insert multiple cross reference in word.
Jan 10 2018 2:20 AM
How to Insert multiple cross reference in word in different place as in word.
If I select different place to insert cross reference in word It is not allowing because Dialog is open. How to fix this one.
Here is my code
public void CrossReferenceItem(Office.IRibbonControl control)
{
Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;
Selection wordSelection = Globals.ThisAddIn.Application.Selection;
UndoRecord recordmacro = app.UndoRecord;
try
{
recordmacro.StartCustomRecord("Cross Reference");
Range oRange;
WdColor oColor_Old;
oRange = Globals.ThisAddIn.Application.Selection.Range;
//'Save current font color
oColor_Old = oRange.Characters[1].Font.Color;
//'Diaplay cross-reference dialog box
var CRDialog = Globals.ThisAddIn.Application.Dialogs[WdWordDialog.wdDialogInsertCrossReference];
//Thread.Sleep(100);
SendKeys.Send("%{H}");
CRDialog.Show();
CRDialog.Update();
//'Include the inserted cross-reference in oRange
oRange.End = Globals.ThisAddIn.Application.Selection.End;
//oRange.Select();
if (oRange.Fields.Count > 0)
{
for (int i = 1; i <= oRange.Fields.Count; i++)
{
oRange.Fields[i].Code.Text = oRange.Fields[i].Code.Text.Replace("MERGEFORMAT", "CHARFORMAT");
oRange.Fields[i].Code.Text = oRange.Fields[i].Code.Text + "\\* CHARFORMAT ";
if (oRange.Fields[i].Code.Text.Contains("\\h"))
{
oRange.Fields[i].Code.Font.Color = WdColor.wdColorBlue;
}
oRange.Fields[i].Update();
}
}
recordmacro.EndCustomRecord();
}
catch (Exception ex) { recordmacro.EndCustomRecord(); }
}
Please any one help me...
Reply
Answers (
2
)
C# - Convert DXF to PDF
windows forms with mvvm