इस मेरे समाधान निम्न आदेश का उपयोग करने के लिए है। प्रतियों, आदि
फ़ाइल नाम के साथ <filename>
बदलें। यदि इसमें रिक्त स्थान हैं तो इसे दोहरे उद्धरण चिह्नों में संलग्न किया जाना चाहिए। (जैसे file.rtf
, "A File.docx"
)
यह में के रूप में एक सिस्टम कॉल के भीतर रखा जा सकता है:
system("start /min winword <filename> /q /n /f /mFilePrint /mFileExit");
यहाँ कार्यों को संभालने है कि इस ताकि आप सभी को याद करने की जरूरत नहीं है के साथ एक सी ++ हेडर फ़ाइल है यदि आप इसे अक्सर उपयोग करते हैं तो स्विच:
/*winword.h
*Includes functions to print Word files more easily
*/
#ifndef WINWORD_H_
#define WINWORD_H_
#include <string.h>
#include <stdlib.h>
//Opens Word minimized, shows the user a dialog box to allow them to
//select the printer, number of copies, etc., and then closes Word
void wordprint(char* filename){
char* command = new char[64 + strlen(filename)];
strcpy(command, "start /min winword \"");
strcat(command, filename);
strcat(command, "\" /q /n /f /mFilePrint /mFileExit");
system(command);
delete command;
}
//Opens the document in Word
void wordopen(char* filename){
char* command = new char[64 + strlen(filename)];
strcpy(command, "start /max winword \"");
strcat(command, filename);
strcat(command, "\" /q /n");
system(command);
delete command;
}
//Opens a copy of the document in Word so the user can save a copy
//without seeing or modifying the original
void wordduplicate(char* filename){
char* command = new char[64 + strlen(filename)];
strcpy(command, "start /max winword \"");
strcat(command, filename);
strcat(command, "\" /q /n /f");
system(command);
delete command;
}
#endif
स्रोत
2011-11-30 21:11:45
यह पूछे जाने वाले प्रश्न का एक बड़ा जवाब है। मैं उन लोगों के लिए इंगित करना चाहता हूं जो इस प्रश्न से अन्य प्रश्नों से जुड़े हुए हैं, यह सर्वर-साइड उपयोग के लिए उपयुक्त नहीं है या जब कोई उपयोगकर्ता लॉग इन नहीं होता है। यह इस प्रश्न की स्थिति नहीं है, लेकिन अन्य प्रश्न भी हैं वह लिंक जो सर्वर-साइड उपयोग के बारे में थे और उन मामलों में Office Automation उपयुक्त नहीं है। डेस्कटॉप पर प्रिंटिंग के लिए, यह पूरी तरह उपयुक्त है। –