【式】
long Selection::MoveLeft ( VARIANT * Unit, VARIANT * Count, VARIANT * Extend );
Unit : (省略可能)移動するユニット
| WdUnits列挙型 |
| 定数 | 値 |
| wdCharacter | 1 |
| wdWord | 2 |
| wdSentence | 3 |
| wdParagraph | 4 |
| wdLine | 5 |
| wdStory | 6 |
| wdScreen | 7 |
| wdSection | 8 |
| wdColumn | 9 |
| wdRow | 10 |
| wdWindow | 11 |
| wdCell | 12 |
| wdCharacterFormatting |
13 |
| wdParagraphFormatting | 14 |
| wdTable | 15 |
| wdItem | 16 |
Extend : (省略可能)カーソル移動上のユニットを選択(既定値 = wdMove)
| WdMovementType列挙型 |
| 定数 | 値 | 内容 |
| wdMove | 0 | 移動 |
| wdExtend | 1 | 選択 |
【サンプル】
//Wordを操作するためのタイプライブラリを読みこむ(Word2000用)
#import "C:\Program Files\Microsoft Office\Office\Mso9.dll" no_namespace rename("DocumentProperties", "DocumentPropertiesDOC")
#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\Vbe6ext.olb" no_namespace
#import "C:\Program Files\Microsoft Office\Office\Msword9.olb" rename("ExitWindows", "ExitWindowsDOC")
using namespace Word;
//Word操作用オブジェクト
_ApplicationPtr pDOC;
_DocumentPtr pDocument;
//Wordの起動
void CImp_word_MoveLeftDlg::OnButton1()
{
//Wordの起動
pDOC.CreateInstance(L"Word.Application");
pDOC->Visible = TRUE;
//新規 Word document を追加する
DocumentsPtr pDocuments = pDOC->GetDocuments();
pDocument = pDocuments->Add();
}
void CImp_word_MoveLeftDlg::OnButton2()
{
COleVariant oleUnit;
COleVariant oleCnt;
oleUnit = (short)wdCharacter;
oleCnt = (short)3;
//カーソル位置を左へ3移動
pDocument->Application->Selection->MoveLeft(oleUnit, oleCnt);
}
//Wordを終了
void CImp_word_MoveLeftDlg::OnButton3()
{
//Wordを終了
pDOC->Quit(COleVariant((short)wdDoNotSaveChanges));
pDOC = NULL;
}
[サンプル・ソース]