Click here to Skip to main content
15,895,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionoperator << inherited? Pin
Budric B.19-Dec-07 11:48
Budric B.19-Dec-07 11:48 
AnswerRe: operator << inherited? Pin
Lea Hayes19-Dec-07 16:15
Lea Hayes19-Dec-07 16:15 
GeneralRe: operator << inherited? Pin
Budric B.20-Dec-07 4:53
Budric B.20-Dec-07 4:53 
GeneralRe: operator << inherited? Pin
Lea Hayes20-Dec-07 12:05
Lea Hayes20-Dec-07 12:05 
Question[Message Deleted] Pin
Simon119-Dec-07 11:25
Simon119-Dec-07 11:25 
GeneralRe: Asking user information, application is started as admin or not? (Windows Vista) Pin
David Crow14-Mar-08 5:55
David Crow14-Mar-08 5:55 
QuestionID3LIB Image Pin
Lucky the code machine19-Dec-07 5:36
Lucky the code machine19-Dec-07 5:36 
GeneralAddOLEObject with LinkToFile on Word 2007 (MFC) Pin
-Dy19-Dec-07 5:30
-Dy19-Dec-07 5:30 
Hi,

I have the following code, which is adding an OLE object to a word document, linking the OLE file to the document so that the document can be moved to another machine without the linked file, and the linked file can still be seen/activated.

When the code executes on a machine with Office XP, the code functions as desired and the resulting .doc file is ~1.5mb (expected). However, when the code is executed on a machine with Office 2007, the code returns no error, but the resulting file is much smaller (~20kb), and when I double click the OLE object to activate it (having removed the linked object to test it's linked correctly), nothing happens. When I right click on the OLE object and select 'Object', I get a message saying "The object is corrupt or is no longer available". It's as though the LinkToFile = true has been ignored by Word 2007 - is that the case? Or is there a problem with my code?
// Start winword
MicrosoftWord :: _Application lApp;
if (!lApp.CreateDispatch(_T("Word.Application")))
{
    AfxMessageBox(_T("sorry old chap, winword's not playing ball"));
    return;
}

// Handy variants
COleVariant lTrue((short) TRUE);
COleVariant lFalse((short) FALSE);
COleVariant lMissing((long) DISP_E_PARAMNOTFOUND, VT_ERROR);

// Documents collection / manager
MicrosoftWord :: Documents lDocsMgr(lApp.GetDocuments());

// Create a new document
MicrosoftWord :: _Document lDoc;
lDoc.AttachDispatch(lDocsMgr.Add(lMissing, lFalse));

// Add an OLE AVI file
MicrosoftWord :: Selection lContent(lApp.GetSelection());

CString aFileName = _T("c:\\temp\\my.avi");
MicrosoftWord :: InlineShapes lShapeCollection(lContent.GetInlineShapes());
lShapeCollection.AddOLEObject(lMissing, COleVariant(aFileName), lTrue, lFalse, lMissing, lMissing, lMissing, lMissing);

// Save the document (c:\temp\abc.doc) & quit
lDoc.SaveAs(COleVariant(_T("c:\\temp\\abc.doc")), lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing);
lDoc.Close(lMissing, lMissing, lMissing);
lApp.Quit(lMissing, lMissing, lMissing);

Many thanks,
- Dylan
- Dy

Generalfocus-button problem Pin
Try19-Dec-07 4:42
Try19-Dec-07 4:42 
Generalreading and writing JPG and GIF Pin
Anthony Appleyard19-Dec-07 4:36
Anthony Appleyard19-Dec-07 4:36 
GeneralRe: reading and writing JPG and GIF Pin
CPallini19-Dec-07 5:17
mveCPallini19-Dec-07 5:17 
GeneralRunning with 8-byte characters Pin
Anthony Appleyard19-Dec-07 4:21
Anthony Appleyard19-Dec-07 4:21 
GeneralRe: Running with 8-byte characters Pin
JudyL_MD19-Dec-07 5:03
JudyL_MD19-Dec-07 5:03 
GeneralRe: Running with 8-byte characters Pin
Anthony Appleyard19-Dec-07 5:10
Anthony Appleyard19-Dec-07 5:10 
GeneralRe: Running with 8-byte characters Pin
CPallini19-Dec-07 5:11
mveCPallini19-Dec-07 5:11 
GeneralRe: Running with 8-byte characters Pin
cmk19-Dec-07 13:14
cmk19-Dec-07 13:14 
GeneralRemote Debugging Pin
Rage19-Dec-07 4:10
professionalRage19-Dec-07 4:10 
GeneralSDI Windows Style Pin
CrocodileBuck19-Dec-07 3:40
CrocodileBuck19-Dec-07 3:40 
GeneralRe: SDI Windows Style Pin
led mike19-Dec-07 4:01
led mike19-Dec-07 4:01 
GeneralRe: SDI Windows Style Pin
CrocodileBuck19-Dec-07 4:11
CrocodileBuck19-Dec-07 4:11 
GeneralRe: SDI Windows Style Pin
led mike19-Dec-07 5:48
led mike19-Dec-07 5:48 
GeneralRe: SDI Windows Style Pin
Mark Salsbery19-Dec-07 6:41
Mark Salsbery19-Dec-07 6:41 
GeneralRe: SDI Windows Style Pin
led mike19-Dec-07 7:16
led mike19-Dec-07 7:16 
GeneralRe: SDI Windows Style Pin
Mark Salsbery19-Dec-07 7:21
Mark Salsbery19-Dec-07 7:21 
GeneralHotkey for menu Item Pin
paresh_joe19-Dec-07 3:19
paresh_joe19-Dec-07 3:19 

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.