Navigating a Range

To go to the next element of a particular type without affecting the selection, you can use the GoTo method of the Range object. GoTo doesn’t affect the Range object it is called on but instead returns a new Range object that represents the resulting Range after calling GoTo. The GoTo method takes by reference four optional object parameters. The first parameter, the What parameter, can be passed a member of the WdGoToItem enumeration:

  • wdGoToBookmark
  • wdGoToComment
  • wdGoToEndnote
  • wdGoToEquation
  • wdGoToField
  • wdGoToFootnote
  • wdGoToGrammaticalError
  • wdGoToGraphic
  • wdGoToHeading
  • wdGoToLine
  • wdGoToObject
  • wdGoToPage
  • wdGoToPercent
  • wdGoToProofreadingError
  • wdGoToRevision
  • wdGoToSection
  • wdGoToTable Lanjutkan membaca Navigating a Range

Identifying a Range

A Range has several properties to help identify it. The get_Information methods takes a parameter of type WdInformation and returns information as an object about the Range depending on the enumerated value that is passed to method. If you call get_Information on a Range with an enumerated type that is not applicable, get_Information will return 1 as a return value.

This is an example of getting information associated with the Range.

[sourcecode language=”csharp”]

public void sampleCode()
{
Object missing = System.Reflection.Missing.Value;
Word.Range r = Globals.ThisAddIn.Application.ActiveDocument.Range(ref missing, ref missing);

r.Text = "This\nis\na\ntest.";

object startIndex = 0;
object endIndex = 9;

Word.Range r2 = Globals.ThisAddIn.Application.ActiveDocument.Range(ref startIndex, ref endIndex);
r2.InsertAfter("\n");

for (int i = 1; i < 27; i++)
{
GetInfo(r2, (Word.WdInformation)i);
}
}

private void GetInfo(Word.Range r, Word.WdInformation info)
{
string result = String.Format(
"Range.Information({0}) returns {1}.\n",
info.ToString(), r.get_Information(info));
r.InsertAfter(result);
}

[/sourcecode]

You can learn output (return value) of the code yourself.

<< BACK

How To Programming Visual Studio Tools for Office

In this post, i’ll share my experience using Visual Studio Tools for Office (VSTO). Basically, VSTO is an addition feature of Visual Studio which is used to harness the power and functionality of Microsoft Office. VSTO is a platform that enables Microsoft Office documents to execute existing code in programming .NET. This doesn’t mean that the VSTO is the only media that available to develop applications based on Microsoft Office. But, VSTO has been designed to make the application easier and more reliable than the available approaches.

For more information about VSTO theory, you can search in Google or MSDN Forum.

In this site, i’ll focused in Microsoft Office Word 2007 only.

Working with Range Object

Getting a Range

You have several ways to get a range in a word document. VSTO have already considered several document-level collections such as Paragraphs, Sentences, Words and Characters that return Range Object. The most common way to get a Range is to use the Range method on the Documen object. Start and End position represent the start and end position of the Range you want to get within the document. If you omit the Start parameter, it defaults to 0, which is the first position in the document. If you omit the End parameter, it defaults to the last position in the document.

In the nampspace code, type this.

[sourcecode language=”csharp”]
using System;
using System.Collections.Generic;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using System.Reflection;
using System.Windows.Forms;
[/sourcecode]

Get all Range

To get all range in the document, type the code bellow:

[sourcecode language=”csharp”]
public void sampleCode()
{
object missingValue = System.Reflection.Missing.Value;
Word.Range range = Globals.ThisAddIn.Application.ActiveDocument.Range(ref missingValue, ref missingValue);
MessageBox.Show(String.Format("{0}", range.Text));
}

[/sourcecode]

MessageBox used for output of the code. Beside it, we know Console.WriteLine. But, MessageBox more efficient. Lanjutkan membaca Getting a Range

Saran

Pada penelitian selanjutnya, disarankan agar add-in ini:

  • dikembangkan sistem lebih lanjut yang dapat mendeteksi bagian-bagian dari skripsi mahasiswa sehingga tidak terpaut pada aturan section Microsoft Office Word 2007,
  • adanya pengembangan lebih lanjut mengenai pengecekan Ejaan Yang Disempurnakan (EYD) pada sistem sehingga sistem memiliki nilai fungsionalitas yang bertambah,
  • bahasa asing yang digunakan tidak hanya mendeteksi Bahasa Inggris, melainkan bahasa asing lainnya meskipun Bahasa Inggris paling sering digunakan dalam penulisan,
  • perlu dikembangkan sebuah sistem cerdas yang mampu membedakan penggunaan bahasa antara Bahasa Indonesia dengan bahasa asing sehingga tidak menghilangkan kata serapan pada kamus bahasa asing,
  • adanya deteksi nama atau variabel yang berbahasa Inggris,
  • pengoreksian skripsi yang tidak hanya pada lingkup skripsi jenjang sarjana (S1) Departemen Ilmu Komputer melainkan seluruh jenjang (diploma, pascasarjana, dan lainnya) serta seluruh jurusan yang ada di Institut Pertanian Bogor.

Kesimpulan

Dari penelitian yang telah dilakukan, dapat disimpulkan:

  • pengembangan sistem ini hanya memberikan peringatan kesalahan pada format dan tidak memanipulasi input yang salah format,
  • adanya nama orang, variabel, produk berbahasa Inggris yang menyebabkan penandaan kesalahan pada dokumen,
  • kesalahan jenis tulisan terjadi pada dokumen yang terdapat simbol-simbol matematika,
  • waktu yang dibutuhkan dalam memeriksa sebuah dokumen bergantung dari jumlah halaman pada dokumen dan jumlah komentar pada dokumen yang tidak sesuai dengan format.