Click here to Skip to main content
15,917,059 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: __stdcall Pin
MailtoGops19-Aug-05 4:14
MailtoGops19-Aug-05 4:14 
GeneralRe: __stdcall Pin
Anton Mikhalyov19-Aug-05 7:06
Anton Mikhalyov19-Aug-05 7:06 
GeneralRe: __stdcall Pin
MailtoGops22-Aug-05 5:40
MailtoGops22-Aug-05 5:40 
GeneralAutomation: How do I select and copy text from a word document Pin
sammiantha18-Aug-05 7:31
sammiantha18-Aug-05 7:31 
GeneralRe: Automation: How do I select and copy text from a word document Pin
David Crow18-Aug-05 7:58
David Crow18-Aug-05 7:58 
GeneralRe: Automation: How do I select and copy text from a word document Pin
gamitech18-Aug-05 9:50
gamitech18-Aug-05 9:50 
GeneralRe: Automation: How do I select and copy text from a word document Pin
Garth J Lancaster18-Aug-05 19:20
professionalGarth J Lancaster18-Aug-05 19:20 
GeneralRe: Automation: How do I select and copy text from a word document Pin
sammiantha20-Aug-05 7:57
sammiantha20-Aug-05 7:57 
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 />
            //Make word Visible and display a message<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
GeneralRe: Automation: How do I select and copy text from a word document Pin
sammiantha20-Aug-05 10:59
sammiantha20-Aug-05 10:59 
GeneralRe: Automation: How do I select and copy text from a word document Pin
Garth J Lancaster20-Aug-05 17:06
professionalGarth J Lancaster20-Aug-05 17:06 
GeneralRe: Automation: How do I select and copy text from a word document Pin
sammiantha21-Aug-05 21:00
sammiantha21-Aug-05 21:00 
GeneralRe: Automation: How do I select and copy text from a word document Pin
Garth J Lancaster21-Aug-05 21:11
professionalGarth J Lancaster21-Aug-05 21:11 
Generalconverting ebcdic to ascii Pin
Camron18-Aug-05 7:30
Camron18-Aug-05 7:30 
GeneralRe: converting ebcdic to ascii Pin
BlackDice18-Aug-05 7:38
BlackDice18-Aug-05 7:38 
GeneralRe: converting ebcdic to ascii Pin
David Crow18-Aug-05 7:51
David Crow18-Aug-05 7:51 
Generalidentifying disk drives and media type Pin
Chintoo72318-Aug-05 7:14
Chintoo72318-Aug-05 7:14 
GeneralRe: identifying disk drives and media type Pin
Ravi Bhavnani18-Aug-05 7:35
professionalRavi Bhavnani18-Aug-05 7:35 
GeneralRe: identifying disk drives and media type Pin
Chintoo72318-Aug-05 7:56
Chintoo72318-Aug-05 7:56 
GeneralRe: identifying disk drives and media type Pin
Ravi Bhavnani18-Aug-05 8:13
professionalRavi Bhavnani18-Aug-05 8:13 
GeneralRe: identifying disk drives and media type Pin
Chintoo72318-Aug-05 8:44
Chintoo72318-Aug-05 8:44 
GeneralOpenGL Pin
Dennis L18-Aug-05 7:10
Dennis L18-Aug-05 7:10 
GeneralRe: OpenGL Pin
johnny18218-Aug-05 12:32
johnny18218-Aug-05 12:32 
GeneralHelp with SetItemData/GetItemData of CTreeCtrl Pin
johnnyXP18-Aug-05 6:43
johnnyXP18-Aug-05 6:43 
GeneralRe: Help with SetItemData/GetItemData of CTreeCtrl Pin
David Crow18-Aug-05 7:57
David Crow18-Aug-05 7:57 
GeneralRe: Help with SetItemData/GetItemData of CTreeCtrl Pin
Anonymous18-Aug-05 9:11
Anonymous18-Aug-05 9:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.