本文整理匯總了C#中Microsoft.Office.Interop.Word.Document類的典型用法代碼示例。如果您正苦於以下問題:C# Document類的具體用法?C# Document怎麽用?C# Document使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Document類屬於Microsoft.Office.Interop.Word命名空間,在下文中一共展示了Document類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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;
}
示例2: Convert
public override void Convert(String inputFile, String outputFile)
{
Object nothing = System.Reflection.Missing.Value;
try
{
if (!File.Exists(inputFile))
{
throw new ConvertException("File not Exists");
}
if (IsPasswordProtected(inputFile))
{
throw new ConvertException("Password Exist");
}
app = new Word.Application();
docs = app.Documents;
doc = docs.Open(inputFile, false, true, false, nothing, nothing, true, nothing, nothing, nothing, nothing, false, false, nothing, true, nothing);
doc.ExportAsFixedFormat(outputFile, Word.WdExportFormat.wdExportFormatPDF, false, Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen, Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument, 1, 1, Word.WdExportItem.wdExportDocumentContent, false, false, Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, false, false, false, nothing);
}
catch (Exception e)
{
release();
throw new ConvertException(e.Message);
}
release();
}
示例3: getAttrValueInTag
public String getAttrValueInTag(String tag, String attr, String subject)
{
if (log.IsInfoEnabled) log.Info("Begin");
if (log.IsDebugEnabled) log.Debug("getAttrValueInTag(tag: " + tag + ", attr: " + attr + ")");
/* Declaración de variables */
String subjectString = null;
String result = null;
String pattern = null;
Regex regexObj = null;
Match matchResults = null;
RegexOptions options = RegexOptions.IgnoreCase;
/* Inicializamos variables */
ActiveDocument = Globals.ThisAddIn.Application.ActiveDocument;
pattern = @"\[" + tag + ".*?" + attr + @"=("".*?""|'.*?'|[^\ \]]*).*?\]";
pattern = "\\[" + tag + ".*?" + attr + "=(\\\".*?\\\"|\\'.*?\\'|[^\\ \\]]*).*?\\]";
subjectString = ActiveDocument.Content.Text;
if (subject != null)
subjectString = subject;
/* Verificamos que haya coincidencia */
regexObj = new Regex(pattern, options);
matchResults = regexObj.Match(subjectString);
if (matchResults.Success)
{
result = matchResults.Groups[1].Value;
if (result.EndsWith("\"") || result.EndsWith("'"))
{
result = result.Substring(1, result.Length - 2);
}
}
if (log.IsInfoEnabled) log.Info("End");
return result;
}
示例4: TechDoc2
public TechDoc2(string TemplateFilename, bool Visible)
{
CurrentTechSection = 0;
CurrentTechLine = 0;
ItemSectionFormat = "{0}. ";
ItemLineFormat = "{0}.{1}. ";
WORDApp = new Word.ApplicationClass();
WORDApp.Visible = true;
object useDefaultValue = Type.Missing;
object visible = Visible;
object template = TemplateFilename;
doc = WORDApp.Documents.Add(ref template, ref useDefaultValue, ref useDefaultValue, ref visible);
//настройка стилей
Word.Style SectionStyle = doc.Styles[Word.WdBuiltinStyle.wdStyleHeading1];
SectionStyle.Font.Color = Word.WdColor.wdColorBlack;
SectionStyle.Font.Name = "Calibri";
SectionStyle.Font.Size = 16;
Word.Style NormalStyle = doc.Styles[Word.WdBuiltinStyle.wdStyleNormal];
NormalStyle.Font.Color = Word.WdColor.wdColorBlack;
NormalStyle.Font.Name = "Calibri";
NormalStyle.Font.Size = 12;
//список таблиц документа
TablesList = new Dictionary<string, Word.Table>();
//список литературы
BiblioList = new List<BiblioSource>();
}
示例5: A
public A()
{
oracon = new OracleConnection("server = 127.0.0.1/orcx; user id = qzdata; password = xie51");
oracon2 = new OracleConnection("server = 10.5.67.11/pdbqz; user id = qzdata; password = qz9401tw");
wordapp = new word.Application();
worddoc = new word.Document();
worddoc = wordapp.Documents.Add();
worddoc.SpellingChecked = false;
worddoc.ShowSpellingErrors = false;
// wordapp.Visible = true;
ta.wordapp = wordapp;
ta.worddoc = worddoc;
if (IS_YEAR)
{
datestr = dsf.GetDateStr(the_year_begin_int, the_month_begin_int, the_year_end_int, the_month_end_int);
}
else
{
datestr = dsf.GetDateStr(the_date);
}
// datestr_abid = "(" + datestr + "and a.ab_id >=1 and a.ab_id <= 7)";
datestr_abid = "(" + datestr + "and" + abidstr + ")";
oracon2.Open();
orahlper = new OraHelper(oracon2);
orahlper.feedback = true;
the_month_begin = new DateTime(the_date.Year, the_date.Month, 1, 0, 0, 0);
the_month_end = the_month_begin.AddMonths(1).AddSeconds(-1);
}
示例6: TEditSidebar
public TEditSidebar(Word.Document WordDoc)
{
InitializeComponent();
AxiomIRISRibbon.Utility.setTheme(this);
this.tabDebug.Visibility = System.Windows.Visibility.Hidden;
if (Globals.ThisAddIn.getDebug())
{
this.tabDebug.Visibility = System.Windows.Visibility.Visible;
}
this.D = Globals.ThisAddIn.getData();
this.Doc = WordDoc;
// Initiatlise the tables to hold the XML
this.DTClauseXML = new DataTable();
this.DTClauseXML.TableName = "ClauseXML";
this.DTClauseXML.Columns.Add(new DataColumn("Id", typeof(String)));
this.DTClauseXML.Columns.Add(new DataColumn("XML", typeof(String)));
this.CurrentConceptId = "";
this.CurrentClauseId = "";
this.CurrentElementId = "";
this.RefreshConceptList();
this.GetDropDowns();
this.ClauseLock = true;
this.ForceRereshClauseXML = false;
}
示例7: WordDocument
public WordDocument(String templateName, bool visible)
{
List<int> startedWords = new List<int>();
foreach (Process p in System.Diagnostics.Process.GetProcessesByName("winword"))
{
startedWords.Add(p.Id);
}
Object missingValue = Missing.Value;
Object template = templateName;
if (wordapp == null)
wordapp = new Word.Application();
foreach (Process p in System.Diagnostics.Process.GetProcessesByName("winword"))
{
if (!startedWords.Contains(p.Id))
{
IDs.Add(p.Id);
}
}
wordapp.Visible = visible;
doc = wordapp.Documents.Add(ref template,
ref missingValue, ref missingValue, ref missingValue);
doc.ActiveWindow.Selection.MoveEnd(Word.WdUnits.wdStory);
tempFileName = Path.Combine(Path.GetDirectoryName(templateName), tempFileName);
}
示例8: setup
public void setup()
{
wordApp = WordApplicationHelper.GetApplication();
if (wordApp.Documents.Exists(IOHelpers.FirmAddressTestData))
wordApp.Documents.First(IOHelpers.FirmAddressTestData).Close(Wd.WdSaveOptions.wdDoNotSaveChanges);
doc = wordApp.Documents.Open(IOHelpers.FirmAddressTestData.FullName);
}
示例9: AddToc
public void AddToc()
{
wordApp = new Application();
object file = filePath;
try
{
wordDocument = wordApp.Documents.Open(ref file, ref paramMissing, ref paramMissing,
ref paramMissing, ref paramMissing, ref paramMissing,
ref paramMissing, ref paramMissing, ref paramMissing,
ref paramMissing, ref paramMissing, ref paramMissing,
ref paramMissing, ref paramMissing, ref paramMissing,
ref paramMissing
);
Range tocRange = wordDocument.Range(0, 0);
TableOfContents toc = wordDocument.TablesOfContents.Add(tocRange, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing);
toc.Update();
int end = toc.Range.End;
Range tocEnd = wordDocument.Range(end, end);
tocEnd.InsertParagraphBefore();
tocEnd.InsertBreak(WdBreakType.wdPageBreak);
}
catch (COMException ex)
{
throw new InvalidOperationException("Invalid Document", ex);
}
finally {
Dispose();
}
}
示例10: WordGenerator
/// <summary>
/// Generates a word instance
/// </summary>
/// <param name="settings"></param>
private WordGenerator(NamedLookup settings, bool silent) : base(settings, silent)
{
app = new Word.Application();
app.Visible = !this.silent;
document = app.Documents.Add(Type.Missing, Type.Missing,
Word.WdNewDocumentType.wdNewBlankDocument, !this.silent);
document.UserControl = !this.silent;
}
示例11: AnnotationDisplay
public AnnotationDisplay(Word.Document doc)
{
this.document = doc;
displayedAnnotations = new List<Microsoft.Office.Interop.Word.Comment>();
document.TextLineEnding = Microsoft.Office.Interop.Word.WdLineEndingType.wdLFOnly;
document.Content.TextRetrievalMode.IncludeFieldCodes = true;
document.Content.TextRetrievalMode.IncludeHiddenText = true;
deletedCharsMap = document.Content.MapDeletedCharsOffsets();
clearContent = document.Content.GetCleanedText();
}
示例12: ComposeDocument
private void ComposeDocument(RepositoryInfo repositoryInfo, IList<Issue> issues, Document document)
{
foreach (Range tmpRange in document.StoryRanges)
{
Replace(repositoryInfo.ProjectName, ProjectNameContainer, tmpRange);
Replace(repositoryInfo.Hash, VersionContainer, tmpRange);
Replace(repositoryInfo.Date, PublicationDateContainer, tmpRange);
Replace(issues.ToText(), SolvedTicketsContainer, tmpRange);
}
}
示例13: ConfirmForm
public ConfirmForm(ThisAddIn myThisAddIn, Word.Application WordApp, object FileName)
{
InitializeComponent();
this.myThisAddIn = myThisAddIn;
this.WordApp = WordApp;
this.FileName = FileName;
OldDocument = WordApp.ActiveDocument;
isCancelFlag = false;
ClosePrintPreviewThread = new Thread(new ThreadStart(ClosePrintPreviewListener));
ClosePrintPreviewThread.Start();
}
示例14: documentListBox_SelectedIndexChanged
private void documentListBox_SelectedIndexChanged(object sender, EventArgs e)
{
// When a document is selected in the list, change the current selected document
if (documentListBox.SelectedIndex >= 0)
{
if (wordObj != null)
{
docObj = wordObj.Documents[documentListBox.SelectedIndex + 1];
}
}
}
示例15: translateButton_Click
private void translateButton_Click(object sender, RibbonControlEventArgs e)
{
document = (Word.Document)inspector.WordEditor;
if (document != null)
{
string selected = document.Application.Selection.Text;
if (selected.Length > 0)
{
document.Application.Selection.Text = translate(selected);
}
}
}