ProgId
Contents
[
Hide
]FieldDde.ProgId property
Gets or sets the application type of the link information.
public string ProgId { get; set; }
Examples
Shows how to use various field types to link to other documents in the local file system, and display their contents.
public void FieldLinkedObjectsAsText(InsertLinkedObjectAs insertLinkedObjectAs)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are three types of fields we can use to display contents from a linked document in the form of text.
// 1 - A LINK field:
builder.Writeln("FieldLink:\n");
InsertFieldLink(builder, insertLinkedObjectAs, "Word.Document.8", MyDir + "Document.docx", null, true);
// 2 - A DDE field:
builder.Writeln("FieldDde:\n");
InsertFieldDde(builder, insertLinkedObjectAs, "Excel.Sheet", MyDir + "Spreadsheet.xlsx",
"Sheet1!R1C1", true, true);
// 3 - A DDEAUTO field:
builder.Writeln("FieldDdeAuto:\n");
InsertFieldDdeAuto(builder, insertLinkedObjectAs, "Excel.Sheet", MyDir + "Spreadsheet.xlsx",
"Sheet1!R1C1", true);
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.LINK.DDE.DDEAUTO.docx");
}
public void FieldLinkedObjectsAsImage(InsertLinkedObjectAs insertLinkedObjectAs)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are three types of fields we can use to display contents from a linked document in the form of an image.
// 1 - A LINK field:
builder.Writeln("FieldLink:\n");
InsertFieldLink(builder, insertLinkedObjectAs, "Excel.Sheet", MyDir + "MySpreadsheet.xlsx",
"Sheet1!R2C2", true);
// 2 - A DDE field:
builder.Writeln("FieldDde:\n");
InsertFieldDde(builder, insertLinkedObjectAs, "Excel.Sheet", MyDir + "Spreadsheet.xlsx",
"Sheet1!R1C1", true, true);
// 3 - A DDEAUTO field:
builder.Writeln("FieldDdeAuto:\n");
InsertFieldDdeAuto(builder, insertLinkedObjectAs, "Excel.Sheet", MyDir + "Spreadsheet.xlsx",
"Sheet1!R1C1", true);
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.LINK.DDE.DDEAUTO.AsImage.docx");
}
/// <summary>
/// Use a document builder to insert a LINK field and set its properties according to parameters.
/// </summary>
private static void InsertFieldLink(DocumentBuilder builder, InsertLinkedObjectAs insertLinkedObjectAs,
string progId, string sourceFullName, string sourceItem, bool shouldAutoUpdate)
{
FieldLink field = (FieldLink)builder.InsertField(FieldType.FieldLink, true);
switch (insertLinkedObjectAs)
{
case InsertLinkedObjectAs.Text:
field.InsertAsText = true;
break;
case InsertLinkedObjectAs.Unicode:
field.InsertAsUnicode = true;
break;
case InsertLinkedObjectAs.Html:
field.InsertAsHtml = true;
break;
case InsertLinkedObjectAs.Rtf:
field.InsertAsRtf = true;
break;
case InsertLinkedObjectAs.Picture:
field.InsertAsPicture = true;
break;
case InsertLinkedObjectAs.Bitmap:
field.InsertAsBitmap = true;
break;
}
field.AutoUpdate = shouldAutoUpdate;
field.ProgId = progId;
field.SourceFullName = sourceFullName;
field.SourceItem = sourceItem;
builder.Writeln("\n");
}
/// <summary>
/// Use a document builder to insert a DDE field, and set its properties according to parameters.
/// </summary>
private static void InsertFieldDde(DocumentBuilder builder, InsertLinkedObjectAs insertLinkedObjectAs, string progId,
string sourceFullName, string sourceItem, bool isLinked, bool shouldAutoUpdate)
{
FieldDde field = (FieldDde)builder.InsertField(FieldType.FieldDDE, true);
switch (insertLinkedObjectAs)
{
case InsertLinkedObjectAs.Text:
field.InsertAsText = true;
break;
case InsertLinkedObjectAs.Unicode:
field.InsertAsUnicode = true;
break;
case InsertLinkedObjectAs.Html:
field.InsertAsHtml = true;
break;
case InsertLinkedObjectAs.Rtf:
field.InsertAsRtf = true;
break;
case InsertLinkedObjectAs.Picture:
field.InsertAsPicture = true;
break;
case InsertLinkedObjectAs.Bitmap:
field.InsertAsBitmap = true;
break;
}
field.AutoUpdate = shouldAutoUpdate;
field.ProgId = progId;
field.SourceFullName = sourceFullName;
field.SourceItem = sourceItem;
field.IsLinked = isLinked;
builder.Writeln("\n");
}
/// <summary>
/// Use a document builder to insert a DDEAUTO, field and set its properties according to parameters.
/// </summary>
private static void InsertFieldDdeAuto(DocumentBuilder builder, InsertLinkedObjectAs insertLinkedObjectAs,
string progId, string sourceFullName, string sourceItem, bool isLinked)
{
FieldDdeAuto field = (FieldDdeAuto)builder.InsertField(FieldType.FieldDDEAuto, true);
switch (insertLinkedObjectAs)
{
case InsertLinkedObjectAs.Text:
field.InsertAsText = true;
break;
case InsertLinkedObjectAs.Unicode:
field.InsertAsUnicode = true;
break;
case InsertLinkedObjectAs.Html:
field.InsertAsHtml = true;
break;
case InsertLinkedObjectAs.Rtf:
field.InsertAsRtf = true;
break;
case InsertLinkedObjectAs.Picture:
field.InsertAsPicture = true;
break;
case InsertLinkedObjectAs.Bitmap:
field.InsertAsBitmap = true;
break;
}
field.ProgId = progId;
field.SourceFullName = sourceFullName;
field.SourceItem = sourceItem;
field.IsLinked = isLinked;
}
public enum InsertLinkedObjectAs
{
// LinkedObjectAsText
Text,
Unicode,
Html,
Rtf,
// LinkedObjectAsImage
Picture,
Bitmap
}
See Also
- class FieldDde
- namespace Aspose.Words.Fields
- assembly Aspose.Words