mfc creates office office software

The last article used the creation of EXEL as an example. Many people have asked what to do with word and ppt. In fact, they are similar to exel, but the individual methods and parameters are different.

The two classes we use to open exel are _CApplication and CWorkbooks (for children's shoes that I don't know how to add, see my previous article), the two classes used by word are _CApplication and CDocuments; the two classes used by ppt _ CApplication, CPresentations, don't think that they are all called _CApplication and they are the same thing, they all have to be added, and when they are added, the names are changed to CApplication_Exel, CApplication_Ppt, CApplication_Word (Actually, you can look in the .h file, their methods are different same oh). Then you need to pay attention not to scribble in the app.CreateDispatch() function, this is fixed, you can't open it if the name is wrong, word is "Word.Application", exel is "Excel.Application", ppt is "" Powerpoint.Application". The last thing to note is that the add function is not the same as the three of them.

word:

CComVariant Template(_T("")); //Document template without WORD  
CComVariant NewTemplate(false),DocumentType(0),Visible; 
docs.Add(&Template,&NewTemplate,&DocumentType,&Visible);

ppt:

ppts.Add(-1); //Empty PPT, the parameter inside is a DWORD

exel:

books.Add(vtMissing);//Default template

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325449065&siteId=291194637