Answered by:
How to get Word-2007 File Format of the current document ?

Question
-
For Excel, the "Workbook" has a property of "FileFormat" which can be passed to SaveAs(). Unfortunately I con not find an equivalent Word propery of "Document". How can I get the file format of the current active document for SaveAs() ?
Thanks
Saturday, March 27, 2010 4:20 PM
Answers
-
- Proposed as answer by Hamed Ahmadi Sunday, March 28, 2010 6:00 PM
- Marked as answer by Ji.Zhou Monday, April 5, 2010 3:56 AM
Sunday, March 28, 2010 7:13 AM -
Hello Takashi,
In Word, there is a function Marco Record. We can use it to record the actions users were doing in Macro format.
If we record a marco and then perform to save the document in different file extensions, then we will see the corresponding enumeration values used in the recorded Marco.
You can see the instructions about Marco Record in the documentation,
http://office.microsoft.com/en-us/word/HA100997691033.aspx
Best regards,
Ji Zhou
MSDN Subscriber Support in Forum
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Ji.Zhou Monday, April 5, 2010 3:57 AM
Friday, April 2, 2010 2:47 AM
All replies
-
- Proposed as answer by Hamed Ahmadi Sunday, March 28, 2010 6:00 PM
- Marked as answer by Ji.Zhou Monday, April 5, 2010 3:56 AM
Sunday, March 28, 2010 7:13 AM -
Hi Hamed,
Thank you very much. I will try to use SaveFormat in Word.
Sunday, March 28, 2010 2:30 PM -
Hi Hamed,
I have a similar question about PowePoint. Which property should I use to get the current "FileFormat" of PowerPoint ? And, if any, which type should I use to pass the value to other variable, such as in int, ... ?
Thanks
Takashi Fukuda
Monday, March 29, 2010 8:47 PM -
Hi Takashi,
You may use Presentation.PpSaveAsFileType. If you do not provide this in the SaveAs method, the default format will be used to save the presentation. Take a look at here. To see the number behind each member of the enum, look here.
Tip: in order to find answer to such questions, you can simply search the method you want to use (i.e. SaveAs in this case) in MSDN website and look what parameters the method takes. There will be a reference to the parameter type in the method description.
BTW, please do not forget to mark the replies that help you as "Answer".
Hamed
Monday, March 29, 2010 9:53 PM -
Hi Hamed,
I am not sure if your answer is what I wanted. For Word, I can use "SaveFormat" (as you suggested) to get the file type from the currently opened document. And for Excel, "FileFormat" property works fine. My question is how to get the current file type from the opened presentation. So far I looked at the MSDN Library. Unfortunately I could not get an answer. Since we need to identify file types of old presentations, it is desired a object property which contained the file type information.
Thanks,
Takashi Fukuda
Tuesday, March 30, 2010 2:39 AM -
Hi Hamed,
I am not sure if your answer is what I wanted. For Word, I can use "SaveFormat" (as you suggested) to get the file type from the currently opened document. And for Excel, "FileFormat" property works fine. My question is how to get the current file type from the opened presentation. So far I looked at the MSDN Library. Unfortunately I could not get an answer. Since we need to identify file types of old presentations, it is desired a object property which contained the file type information.
Thanks,
Takashi Fukuda
Tuesday, March 30, 2010 2:39 AM -
Unfortunately I am not aware of such property. I am not sure if an equivalent of Document.SaveFormat exists for Presentation. you may find this out by checking the file extension.
can you explain what your scenario is? why do you need to know the type of an existing presentation?
Hamed
Tuesday, March 30, 2010 4:39 AM -
Hi Hamed,
As far as I looked at the WdSaveFormat enumeration table, there are 3x file formats for Word document, and 4x texts:
wdFormatDocument, wdFormatDocumentDefault, wdFormatDocument97 (for 2x file extensions: .doc and .docx ?)
wdFormatEncodedText, wdFormatText, wdFormatTextLineBreaks, wdFormatUnicodeText, (for 1x extension: .txt ?)
How can I differenciate them with file extensions ? I may be missing something.
Thanks,
Takashi Fukuda
Tuesday, March 30, 2010 12:44 PM -
Hello Takashi,
In Word, there is a function Marco Record. We can use it to record the actions users were doing in Macro format.
If we record a marco and then perform to save the document in different file extensions, then we will see the corresponding enumeration values used in the recorded Marco.
You can see the instructions about Marco Record in the documentation,
http://office.microsoft.com/en-us/word/HA100997691033.aspx
Best regards,
Ji Zhou
MSDN Subscriber Support in Forum
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Ji.Zhou Monday, April 5, 2010 3:57 AM
Friday, April 2, 2010 2:47 AM