|
I know how to start Word and open 2 word documents - one existing and one new. I want to copy specific pages from the existing word document and paste them one at a time into the new document. So far I haven't even managed to copy any text of any description, my paste is just pasting whatever happened to be on the clipboard before.
|
|
|
|
|
sammiantha wrote:
I know how to start Word and open 2 word documents...
Briefly, how are you doing this?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Probably ShellExecute ...!?!?
gabby
|
|
|
|
|
Are you doing this in VB/VBA/c++/??
If I were doing it in c++, I'd embed the type library in my program, use the Word Automation objects to create an instance of Word, open a document, then use (sketchy becuase I dont have the details right in front of me) a select/range object to define a range of pages/paragraphs/lines within the document (which may be all), then execute the copy method .. then create a new document, select the 1st line, and execute the paste method ..
it may be the selecting text thats causing you grief - you havnt said you're defining what to copy/how you're marking the text
if you post some code I can take a look over the weekend if I get time (Its Friday afternoon here)
'G'
|
|
|
|
|
Garth J Lancaster wrote:
If I were doing it in c++, I'd embed the type library in my program, use the Word Automation objects to create an instance of Word, open a document, then use (sketchy becuase I dont have the details right in front of me) a select/range object to define a range of pages/paragraphs/lines within the document (which may be all), then execute the copy method .. then create a new document, select the 1st line, and execute the paste method ..
I'm using c++.
Okay, remember that I'm new to this automation - and my code may be awful for someone who actually knows what they are doing.
G, I am with you, up until 'use a select/range object to define a range...' which is where my trouble begins.
Basically I used this KB article to get started:
http://www.kbalertz.com/Feedback.aspx?kbNumber=178749[^]
(obviously using Word not Excel).
Then I have the following:
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR),<br />
vtTrue((short)TRUE),<br />
vtFalse((short)FALSE);<br />
<br />
<br />
_Application app; <br />
Documents oDocs;<br />
_Document oDoc;<br />
_Document newDoc;<br />
Paragraphs oParagraphs;<br />
Selection oSelection;<br />
COleVariant fileName;<br />
fileName = "C:\\Program Files\\Microsoft Visual Studio\\MyProjects\\ReadingRecs\\file.doc";<br />
<br />
if(!app.CreateDispatch("Word.Application"))<br />
{<br />
AfxMessageBox("Couldn't start Word.");<br />
}<br />
else<br />
{ AfxMessageBox("Word opened.");<br />
app.SetVisible(TRUE);<br />
<br />
oDocs = app.GetDocuments();<br />
oDoc = oDocs.Open(fileName,vtOptional, vtOptional,vtOptional, vtOptional, vtOptional,vtOptional, vtOptional, vtOptional,vtOptional, vtOptional, vtOptional);<br />
<br />
fileName = "c:\\files\\temp.doc";<br />
newDoc = oDocs.Add(fileName,vtOptional, vtOptional, vtOptional);<br />
<br />
}
I attempted to use another vaguely relevant KB article: http://www.kbalertz.com/kb_220911.aspx[^] which is where I found the document opening/creating stuff.
Any help anyone could give me would be great.
-Samantha
|
|
|
|
|
Problem solved.
Solution: Stop wondering aimlessly around the classes that word has to offer - create a macro to do the selection and run that macro using Application.Run() from c++ program.
|
|
|
|
|
|
I'd been told by many to make a macro and convert the VB code to c++; that it was easy. That didn't work out for me. Then someone mentioned the Application.Run() function and after figuring out how to use that, I'll be using macros wherever possible from now on! The only problem I can see with that though, is that I won't be able to use the program on just any computer. It won't work unless the right macro is in normal.dot. So my next job will be looking for an easy way to install my macro when the program runs for the first time.
There will also be a problem when I try to use the program on a different version of word - because automation makes you use a different header file depending on the version.
Why I create these projects for myself I don't know...
|
|
|
|
|
Hey - its a challenge, that 1) you didnt give up on and 2) you're willing to keep trying at - so dont knock yourself, and give yourself some credit - you didnt find the answer the first time but you got it a different way, maybe sometime later you'll be browsing some code and it'll click - your tenacity puts you ahead of lots of people who would have chucked it in the 'too hard' basket
Do when/if you get time download the samples etc and have a look through them - you might just spot the missing link ..
'G'
|
|
|
|
|
I need a program to convert my text from ebcdic to ascii. Is there any tutorial or code out there that will help me do this?
|
|
|
|
|
here's a function I used before: However, mine returns it as a string, so you'll have to do any other conversion on it yourself
CString EBCDICToDecimal(CString strValue)
{
CString chr;
char cEnd;
int nLength = strValue.GetLength();
cEnd = strValue[nLength - 1];
chr = "";
if((cEnd >= 65) && (cEnd <= 73)) cEnd -= 16;
if(cEnd == 123) cEnd = 48;
if(cEnd == 125)
{
chr = "-";
cEnd = 48;
}
if((cEnd >= 74) && (cEnd <= 82))
{
chr = "-";
cEnd -= 25;
}
strValue = chr + strValue.Left(strValue.GetLength() - 1) + cEnd;
return strValue;
}
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
See if this helps. In addition, there's these two:
http://support.microsoft.com/kb/216399/EN-US/
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q235856
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi,
FindFirstFile API can list the files/folders in a given folder, but I need to find out what all drives are available on the system(like C:, D:, etc) and what are the media types (like harddrive, cd-drive, usb-drive, etc). Does any one have some idea to figure this out using windows file APIs?
Thanks
~f
|
|
|
|
|
|
Thanks for that link. GetDriveType takes the drive letter as part of the argument, and I dont know how to obtain the list of drive letters available. I looked at the volume management functions, ([^]) but this example doesnt give the drive letter information. What is a volume, and what are mount points, if I may ask?
Thanks
~f
|
|
|
|
|
|
|
Hi everybody!
I'm trying to find an answer on how to render a text in OpenGL and having it always in front of every object independingly of its z value. The text is placed using glRasterPos3d()..
(I don't want to use glOrtho() because I want the text to be moved in relationship with the camera)
Thanks for every answear!
|
|
|
|
|
You can disable the z-buffer by calling glDisable(GL_DEPTH_TEST), render the text, and re-enable z-buffer.
|
|
|
|
|
I have a dialog based class named CJKDlg, with a tree control with name treeTracks.
In the JKDlg.h i have defined the following structure:
struct _itemData
{
CString strData;
};
In the OK click event i have the following handler:
void CJKDlg::OnBnClickedOk()
{
CStdioFile stdFile;
CString str;
if(! stdFile.Open("test.txt", CFile::modeRead))
{
AfxMessageBox("Cannot find initialization file", MB_OK, MB_ICONSTOP);
return;
}
TVINSERTSTRUCT tvInsert;
tvInsert.hParent = NULL;
tvInsert.hInsertAfter = NULL;
tvInsert.item.mask = TVIF_TEXT;
HTREEITEM hAlbum, hItem;
char ch;
CString albumTitle, trackTitle, trackPath;
_itemData* pItemData = new _itemData();
while(stdFile.ReadString(str))
{
ch = str.GetAt(0);
if(ch=='$')
{
albumTitle = str.Right(str.GetLength()-1);
tvInsert.item.pszText = albumTitle.GetBuffer(albumTitle.GetLength());
hAlbum = m_treeTracks.InsertItem(&tvInsert);
pItemData->strData = "OK";
m_treeTracks.SetItemData(hAlbum, DWORD(pItemData));
}
}
delete pItemData;
}
In last a double-click event handler for the tree control:
void CJKDlg::OnNMDblclkTreeTracks(NMHDR *pNMHDR, LRESULT *pResult)
{
HTREEITEM hItem = m_treeTracks.GetSelectedItem();
ASSERT(hItem);
_itemData* pItemData = new _itemData();
pItemData = (_itemData *)m_treeTracks.GetItemData(hItem);
if(pItemData)
{
TRACE1("%s\n", pItemData->strData);
}
delete pItemData;
*pResult = 0;
}
The TRACE macro dose not display the "OK" string. Instead in the output window a white space displayed.
Can anyone help me with this please?
|
|
|
|
|
johnnyXP wrote:
m_treeTracks.SetItemData(hAlbum, DWORD(pItemData));
You are inserting the same pItemData for each node in the tree. Is that intentional?
johnnyXP wrote:
delete pItemData;
This is why nothing shows up.
johnnyXP wrote:
_itemData* pItemData = new _itemData();
This statement is unnecessary in OnNMDblclkTreeTracks() . Memory was allocated in OnBnClickedOk() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Daim you are right! The data is not the same for each node. I do that just to simplify the question and the code.
Thanks a lot for your time.
|
|
|
|
|
Hey,
i build a nice custom control (::from CWnd). It works perfect on dialogs but can't print it.
I tried to create the control in my CView::OnPrint function --> Success.
But I never come to my OnPaint function. How can I print my control? Do I have to implement a special function with a parameter-handle to my printing DC?
|
|
|
|
|
Hi ,
I would like to draw opengl inside the frame of a simple html page running through IE or Firefox.
I already can draw opengl on windows Desktop but i do not know how to draw on internet directly.
please post some code to achieve that.
thanks.
|
|
|
|
|
If given a region (could be CRgn or even just an area described by a CRect), is there a way to check if that region only contains background color (nothing really drawn in there, i.e., no characters, dots, etc)? The simplist way I could think is looping through the region and getting each pixel via the CDC::GetPixel () method, and checking it against the background color. I am basically looking for a way to determine if something is drawn in a specific area.
I was hoping if there was a more "elegant" solution. Searches both here and on the 'Net as a whole seemed to turn up nothing regarding this.
Thanks
Steven Konopa
|
|
|
|