カーソル位置を左へ移動させる


【式】

	long Selection::MoveLeft ( VARIANT * Unit, VARIANT * Count, VARIANT * Extend );

Unit : (省略可能)移動するユニット
WdUnits列挙型
定数
wdCharacter1
wdWord2
wdSentence3
wdParagraph4
wdLine5
wdStory6
wdScreen7
wdSection8
wdColumn9
wdRow10
wdWindow11
wdCell12
wdCharacterFormatting 13
wdParagraphFormatting14
wdTable15
wdItem16
Extend : (省略可能)カーソル移動上のユニットを選択(既定値 = wdMove)
WdMovementType列挙型
定数内容
wdMove0移動
wdExtend1選択
【サンプル】 //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; } [サンプル・ソース]