Hello everyone!
I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.
I have a Word document with a table, which has following format: 4 columns, 40 rows.
In a dialog box I have a listview that has data which goes to Word table.
In the code bellow, I check if number of items is greater than 40, and if is, I add ( NumberOfItems ) - 40 new rows, using method InsertRowBelow.
Then I type some text to test things, and it types text at proper place - current selection is the last added row.
Then I try to move up and type some text in the row before the last one, but selection moves 28 lines below the last inserted row, and types text.
If I don't insert any rows, it works OK.
I work with OLE and C++ automation.
I have used examples from these links:
How to insert text into tables in MS WORD ?[
^]
My question is:
How can I fix my code to move up to the first row, after I have added new rows
{
hr = AutoWrap( DISPATCH_METHOD, NULL, pSel, L"MoveDown", 0 );
if( ListView_GetItemCount( GetDlgItem( hwnd, IDC_LIST1 ) ) > 40 )
for( int i = 0; i <
(int)( ListView_GetItemCount( GetDlgItem( hwnd, IDC_LIST1 ) ) - 40 );
i++ )
{
hr = AutoWrap( DISPATCH_METHOD, NULL, pSel, L"InsertRowsBelow", 0 );
}
VARIANT xx;
xx.vt = VT_BSTR;
xx.bstrVal = ::SysAllocString(L"rows");
hr = AutoWrap( DISPATCH_METHOD, NULL, pSel, L"TypeText", 1, xx );
hr = AutoWrap( DISPATCH_METHOD, NULL, pSel, L"MoveUp", 0 );
VARIANT x;
x.vt = VT_BSTR;
x.bstrVal = ::SysAllocString(L"TEST");
hr = AutoWrap( DISPATCH_METHOD, NULL, pSel, L"TypeText", 1, x );
}
I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.
If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.