Skip to content

Commit

Permalink
Restored missing files/refactored projects
Browse files Browse the repository at this point in the history
  • Loading branch information
romans91 committed Mar 18, 2021
1 parent 4ba35a0 commit c5a4dee
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Word.Application wordApp = Application;

wordApp.Documents.Open("Add Bookmark.doc");
string filePath = @"..\..\..\..\..\Sample Files\";

wordApp.Documents.Open(filePath + "MyDocument.docx");

Document extendedDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
Bookmark firstParagraph = extendedDocument.Controls.AddBookmark(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string mypath = "";
Word.Application wordApp = Application;
wordApp.Documents.Open(mypath + "Add Headers and Footers.doc");

//Add Header
string filePath = @"..\..\..\..\..\Sample Files\";

wordApp.Documents.Open(filePath + "MyDocument.docx");

// Add a header.
foreach (Word.Section section in this.Application.ActiveDocument.Sections)
{
Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
}

//Add Footer
// Add a footer.
foreach (Word.Section wordSection in this.Application.ActiveDocument.Sections)
{
Word.Range footerRange = wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@ static void Main(string[] args)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a shape which contains and displays an image taken from a file in the local file system.
builder.InsertImage("download.jpg");
string filePath = @"..\..\..\..\..\Sample Files\";

// Insert a shape into the document with an image taken from a file in the local file system.
builder.InsertImage(filePath + "Logo.jpg");

// Insert a shape which contains WordArt with customized text.
Shape shape = new Shape(doc, ShapeType.TextPlainText)
{
WrapType = WrapType.Inline,
Width = 480,
Height = 24,
FillColor = Color.Orange,
StrokeColor = Color.Red
};
Shape wordArtShape = new Shape(doc, ShapeType.TextCurve);
wordArtShape.Width = 480;
wordArtShape.Height = 24;
wordArtShape.FillColor = Color.Orange;
wordArtShape.StrokeColor = Color.Red;
wordArtShape.WrapType = WrapType.Inline;

wordArtShape.TextPath.FontFamily = "Arial";
wordArtShape.TextPath.Bold = true;
wordArtShape.TextPath.Italic = true;
wordArtShape.TextPath.Text = "Hello World! This text is bold, and italic.";

shape.TextPath.FontFamily = "Arial";
shape.TextPath.Bold = true;
shape.TextPath.Italic = true;
shape.TextPath.Text = "Hello World! This text is bold, and italic.";
doc.FirstSection.Body.LastParagraph.AppendChild(wordArtShape);

doc.Save("Add Picture and WordArt.docx");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;

namespace VSTO_Words
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string mypath = "";
string filePath = @"..\..\..\..\..\Sample Files\";

Word.Application wordApp = Application;
wordApp.Documents.Open(mypath+"Add Picture and WordArt.doc");
wordApp.Documents.Open(filePath + "MyDocument.docx");
//Add picture to Doc
this.Application.Selection.InlineShapes.AddPicture(mypath+"download.jpg");
this.Application.Selection.InlineShapes.AddPicture(filePath + "Logo.jpg");

//Add WordArt
//Get the left and top position of the current cursor location.
// Add WordArt.
// Get the left and top position of the current cursor location.
float leftPosition = (float)this.Application.Selection.Information[
Word.WdInformation.wdHorizontalPositionRelativeToPage];

float topPosition = (float)this.Application.Selection.Information[
Word.WdInformation.wdVerticalPositionRelativeToPage];

//Call the AddTextEffect method of the Shapes object of the active document (or a different document that you specify).

// Call the AddTextEffect method of the Shapes object of the active document (or a different document that you specify).
this.Application.ActiveDocument.Shapes.AddTextEffect(Office.MsoPresetTextEffect.msoTextEffect29, "test","Arial Black", 24, Office.MsoTriState.msoFalse,
Office.MsoTriState.msoFalse, leftPosition, topPosition);

}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ static void Main(string[] args)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

string filePath = @"..\..\..\..\..\Sample Files\";

// Insert a shape into the document with an image taken from a file in the local file system.
builder.InsertImage("download.jpg");
builder.InsertImage(filePath + "Logo.jpg");

doc.Save("Add Picture.docx");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string mypath = "";
string filePath = @"..\..\..\..\..\Sample Files\";
Word.Application wordApp = Application;
wordApp.Documents.Open(mypath+"Add Picture.doc");
//Add picture to Doc
this.Application.Selection.InlineShapes.AddPicture(mypath+"download.jpg");


wordApp.Documents.Open(filePath + "MyDocument.docx");

// Insert an image into the document.
this.Application.Selection.InlineShapes.AddPicture(filePath + "Logo.jpg");
}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ static void Main(string[] args)

// If we wish to apply page setup changes to an entire document, we will need to iterate over every section.
foreach (Section section in doc)
section.PageSetup.PaperSize = PaperSize.Letter;
section.PageSetup.PaperSize = PaperSize.EnvelopeDL;

doc.Save("Section.ModifyPageSetupInAllSections.docx");
doc.Save("Changing Page Setup for Whole Document.docx");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using Word = Microsoft.Office.Interop.Word;

namespace VSTO_Words
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;

namespace VSTO_Words
namespace VSTO_Words
{
public partial class ThisAddIn
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ static void Main(string[] args)
{
table.PreferredWidth = PreferredWidth.FromPercent(100);
}

doc.Save("Fitting all Tables to the Page Width.docx");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using Word = Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop.Word;

namespace VSTO_Words
Expand All @@ -14,9 +7,10 @@ public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string mypath = "Document.docx";
string filePath = @"..\..\..\..\..\Sample Files\";
Word.Application wordApp = Application;
wordApp.Documents.Open(mypath);

wordApp.Documents.Open(filePath + "MyDocument.docx");

foreach (Table table in this.Application.ActiveDocument.Tables)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using Word = Microsoft.Office.Interop.Word;

namespace VSTO_Words
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string mypath = "Document.docx";
string filePath = @"..\..\..\..\..\Sample Files\";
Word.Application wordApp = Application;
wordApp.Documents.Open(mypath);

wordApp.Documents.Open(filePath + "MyDocument.docx");

int recordCount = 2;
int i = 0;
for (i = 0; i <= recordCount; i++)
wordApp.Selection.WholeStory();
wordApp.Selection.EndOf();
wordApp.Selection.InsertFile("DetailsList.docx");
wordApp.Selection.InsertFile(filePath + "MyDocument.docx");

if (i < recordCount)
{
wordApp.Selection.Range.InsertBreak(2);
}
if (i > 1)
{

//wordApp.ActiveDocument.Sections(i).Headers(1).LinkToPrevious = false;
}

}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using Word = Microsoft.Office.Interop.Word;

namespace VSTO_Words
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using Word = Microsoft.Office.Interop.Word;

namespace VSTO_Words
{
Expand All @@ -14,7 +7,7 @@ public partial class ThisAddIn
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
object noReset = false;
object password = System.String.Empty;
object password = "MyPassword";
object useIRM = false;
object enforceStyleLock = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;

namespace VSTO_Words
namespace VSTO_Words
{
public partial class ThisAddIn
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string mypath = "";

Word.Document doc = Application.Documents.Open(mypath+"Add Headers and Footers.doc");
Globals.ThisAddIn.Application.ActiveDocument.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs.Last.Range.Delete();
Globals.ThisAddIn.Application.ActiveDocument.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs.Last.Range.Delete();

string filePath = @"..\..\..\..\..\Sample Files\";
Word.Application wordApp = Application;

Word.Document doc = wordApp.Documents.Open(filePath + "MyDocument.docx");

Globals.ThisAddIn.Application.ActiveDocument.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs.Last.Range.Delete();
Globals.ThisAddIn.Application.ActiveDocument.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs.Last.Range.Delete();
}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ static void Main(string[] args)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("find me");
builder.Writeln("Hello world!");

FindReplaceOptions options = new FindReplaceOptions
{
MatchCase = false,
FindWholeWordsOnly = true
};

doc.Range.Replace("find me", "found", options);
doc.Range.Replace("Hello world!", "Greetings planet!", options);

doc.Save("Search for and Replace text.docx");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string mypath = "";
string filePath = @"..\..\..\..\..\Sample Files\";
Word.Application wordApp = Application;
wordApp.Documents.Open(mypath + "Search and Replace.doc");

wordApp.Documents.Open(filePath + "MyDocument.docx");

object replaceAll = Word.WdReplace.wdReplaceAll;

this.Application.Selection.Find.ClearFormatting();
this.Application.Selection.Find.Text = "find me";
this.Application.Selection.Find.Text = "Hello world!";

this.Application.Selection.Find.Replacement.ClearFormatting();
this.Application.Selection.Find.Replacement.Text = "Found";
this.Application.Selection.Find.Replacement.Text = "Greetings planet!";

this.Application.Selection.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c5a4dee

Please sign in to comment.