本文整理汇总了C#中Microsoft.Office.Interop.Word类的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Word类的具体用法?C# Microsoft.Office.Interop.Word怎么用?C# Microsoft.Office.Interop.Word使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Microsoft.Office.Interop.Word类属于命名空间,在下文中一共展示了Microsoft.Office.Interop.Word类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HumanMacroDialog
public HumanMacroDialog(Word.Range text, int jobNumber)
{
this.text = text;
this.jobNumber = jobNumber;
InitializeComponent();
Binding binding = new Binding();
binding.Source = text;
binding.Path = new PropertyPath("Text");
textToWorkWith.SetBinding(TextBox.TextProperty, binding);
numItems.Content = numSections + " paragraph" + (numSections == 1 ? "" : "s") + " selected, each as a separate task";
item1 = new ComboBoxItem();
item1.Content = "Paragraph";
item2 = new ComboBoxItem();
item2.Content = "Sentence";
separatorBox.Items.Add(item1);
separatorBox.Items.Add(item2);
separatorBox.SelectedValue = item1;
returnAsComments = new ComboBoxItem();
returnAsComments.Content = "Comments";
returnAsInline = new ComboBoxItem();
returnAsInline.Content = "In-Line Changes";
returnTypeBox.Items.Add(returnAsComments);
returnTypeBox.Items.Add(returnAsInline);
returnTypeBox.SelectedValue = returnAsComments;
}
示例2: UrlListForm
public UrlListForm(Word.Document doc)
{
InitializeComponent();
if (doc == null)
return;
wordDoc = doc;
hyperlink_urls = WordUrlManager.GetListOfHyperlinkUrls(doc);
hyperlink_requests = new HttpWebRequest[hyperlink_urls.Length];
autofind_urls = WordUrlManager.GetListOfAllUrls(doc);
autofind_requests = new HttpWebRequest[autofind_urls.Length];
active_urls = hyperlink_urls;
active_requests = hyperlink_requests;
InitializeUrlViewList();
progressBar.Visible = true;
if (active_urls.Length == 0)
progressBar.Visible = false;
progressBar.Minimum = 0;
progressBar.Maximum = active_urls.Length;
progressBar.Step = 1;
progressBar.Value = 0;
button_RecheckEveryURL.Enabled = false;
radioButton_autofindUrls.Enabled = false;
radioButton_wordHyperlinks.Enabled = false;
listView.BeginUpdate();
urlTesterThread = null;
RestartTestingThread = null;
urlTesterThread_shouldStop = false;
}
示例3: FormFormatDate
public FormFormatDate(Word.ContentControl currentCC)
{
InitializeComponent();
this.currentCC = currentCC;
if (currentCC.XMLMapping.IsMapped)
{
String dateValue = currentCC.XMLMapping.CustomXMLNode.Text;
if (!DateTime.TryParse(dateValue, out thisDate1)) {
thisDate1 = DateTime.Now;
}
}
else
{
thisDate1 = DateTime.Now;
}
for (int i = 0; i < formatValues.Length; i++)
{
FormatChoice fc = new FormatChoice();
fc.format = formatValues[i];
fc.display = thisDate1.ToString(fc.format);
this.listBoxFormat.Items.Add(fc);
}
if (currentCC.DateDisplayFormat != null)
{
this.textBoxFormat.Text = currentCC.DateDisplayFormat;
}
}
示例4: areOpenDoPEPartsPresent
public static bool areOpenDoPEPartsPresent(Word.Document document)
{
// TODO consider removing this, or moving it,
// refer instead Model.cs
// Modified from OpenDoPE_Wed ThisAddIn
Office.CustomXMLPart xpathsPart = null;
Office.CustomXMLPart conditionsPart = null;
foreach (Office.CustomXMLPart cp in document.CustomXMLParts)
{
if (cp.NamespaceURI.Equals(Namespaces.XPATHS))
{
// check for duplicate parts; introduced 2013 12 08
if (xpathsPart != null)
{
MessageBox.Show("Duplicate parts detected. This template needs to be manually repaired. Please contact your help desk.");
}
xpathsPart = cp;
}
else if (cp.NamespaceURI.Equals(Namespaces.CONDITIONS))
{
conditionsPart = cp;
}
}
return (xpathsPart != null && conditionsPart != null);
}
示例5: collectWord
public string collectWord(Word.Document doc)
{
doc.ActiveWindow.Selection.WholeStory();
string str = doc.ActiveWindow.Selection.Text;
return analyze(str);
}
示例6: ProcessParagraphs
protected bool ProcessParagraphs(OfficeDocumentProcessor aWordProcessor, Word.Paragraphs aParagraphs)
{
foreach (Word.Paragraph aParagraph in aParagraphs)
{
// get the Range object for this paragraph
Word.Range aParagraphRange = aParagraph.Range;
// if we're picking up where we left off and we're not there yet...
int nCharIndex = 0;
if (aWordProcessor.AreLeftOvers)
{
if (aWordProcessor.LeftOvers.Start > aParagraphRange.End)
continue; // skip to the next paragraph
nCharIndex = aWordProcessor.LeftOvers.StartIndex;
aWordProcessor.LeftOvers = null; // turn off "left overs"
}
WordRange aThisParagraph = new WordRange(aParagraphRange);
if (!ProcessRangeAsWords(aWordProcessor, aThisParagraph, nCharIndex))
return false;
}
return true;
}
示例7: getRepeatAncestor
public Word.ContentControl getRepeatAncestor(Word.ContentControl cc)
{
Word.ContentControl repeatAncestor = null;
if (root != null
&& !treeViewRepeat.SelectedNode.Equals(root)) // this varies with some repeat
{
// Which one is checked?
string variesInRepeatId = (string)treeViewRepeat.SelectedNode.Tag;
Word.ContentControl currentCC = cc.ParentContentControl;
while (repeatAncestor == null && currentCC != null)
{
if (currentCC.Tag.Contains("od:repeat"))
{
TagData td = new TagData(currentCC.Tag);
string variesXPathID = td.getRepeatID();
if (variesXPathID.Equals(variesInRepeatId))
{
return currentCC;
}
}
currentCC = currentCC.ParentContentControl;
}
}
return null;
}
示例8: WordActiveDocument
public WordActiveDocument(IOfficeApplication application, MsWord._Document document)
: base(application, document.FullName)
{
_document = document;
InitializeWsDocument(FullPath);
}
示例9: WordUrlManager
public WordUrlManager(Word.Application wordApp)
{
Word.Options options = wordApp.Application.Options;
originalSettings_ReplaceHyperlinks = options.AutoFormatReplaceHyperlinks;
originalSettings_AsYouTypeReplaceHyperlinks = options.AutoFormatAsYouTypeReplaceHyperlinks;
wordAppOptionsChanged = false;
}
示例10: OpenDocument
//private static Word.Application wordapp = new Word.Application();
public static Document OpenDocument(Word.Application wordapp, string fileName)
{
wordapp.Visible = true;
//Setting for open
string FileName = fileName;
bool ConfirmConversions = false;
bool ReadOnly = false;
bool AddToRecentFiles = false;
object PasswordDocument = missing;
object PasswordTemplate = missing;
bool Revert = false;
object WritePasswordDocument = missing;
object WritePasswordTemplate = missing;
object Format = missing;
object Encoding = missing;
bool Visible = true;
bool OpenAndRepair = true;
object DocumentDirection = missing;
bool NoEncodingDialog = false;
object XMLTransform = missing;
//
return wordapp.Documents.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
WritePasswordTemplate, Format, Encoding, Visible, OpenAndRepair,
DocumentDirection = missing, NoEncodingDialog, XMLTransform);
}
示例11: CreateContact
private WorkContact CreateContact(Word.Row row, WorkGroup latestGroup)
{
try
{
//Trainers, Misc and Office have strange formats so don't do them
if (latestGroup != WorkGroup.Trainer && latestGroup != WorkGroup.Misc && latestGroup != WorkGroup.Office)
{
string nameAndInitials = GetNameAndInitials(row);
string[] nameFields = nameAndInitials.Split(' ');
string firstname = GetFirstName(nameFields);
string surname = GetSurname(nameFields);
string initials = GetInitials(nameFields);
string mobile = GetMobileNumber(row);
string home = GetHomeNumber(row);
//if there is at least one number then we can reasonably assume it's a contact
if (!string.IsNullOrWhiteSpace(mobile) || !string.IsNullOrWhiteSpace(home))
{
return WorkContact.FactoryCreate(firstname, surname, initials, mobile, home, latestGroup);
}
}
}
catch (Exception e)
{
Console.WriteLine("Had the following exception: " + e.Message);
Console.WriteLine(e.StackTrace);
}
return null;
}
示例12: OpenNewApplication
public static void OpenNewApplication(Word.Application WordApp, object FileName)
{
WordApp.Documents.Open(ref FileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); //新的程序打开原文档
}
示例13: showHome
public void showHome(Word.Application WordApp)
{
this.UseWordApp = WordApp;
this.webBrowser1.ObjectForScripting = this;
this.webBrowser1.Navigate(new Uri("http://localhost:8080/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/office/my_alfresco.ftl&contextPath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/office/my_alfresco.ftl"));
//this.webBrowser1.Navigate(new Uri("http://www.alfresco.com"));
}
示例14: AddDetailsControl
protected Wd.ContentControl AddDetailsControl(Wd.Range range)
{
var detailsControl = range.ContentControls.Add_Safely(Wd.WdContentControlType.wdContentControlText);
detailsControl.Title = control.Title + " Details";
detailsControl.Tag = control.Tag.Remove(" Delivery") + " Details";
return detailsControl;
}
示例15: UpdateControls
public Wd.Range UpdateControls(IList<Contact> contacts, Wd.WdCollapseDirection CollapseDirection = Wd.WdCollapseDirection.wdCollapseEnd)
{
try
{
var control = doc.ContentControls(x => x.Tag == controlTags.First()).First();
var range = control.ParentContentControl.Range;
range.MoveEnd(Wd.WdUnits.wdParagraph, 1);
range.Copy();
range.ContentControls.DeleteEmpty();
range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd);
for (int i = 2; i <= contacts.Count; i++)
{
range.MoveOutOfContentControl();
range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd);
range.Paste();
UpdateContentControlMappings(range, i);
range.ContentControls.DeleteEmpty();
}
range = range.CollapseEnd();
if (range.Paragraphs[1].IsEmpty())
range.Paragraphs[1].Range.Delete();
doc.Bookmarks.DeleteIfExists(Bookmarks);
UpdateDeliveryDetails();
range.Move(Wd.WdUnits.wdCharacter, 1);
return range;
}
finally
{
ClipboardHelper.Clear();
}
}