By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

Word as com object reading a byte array instead of a temp file.

P: n/a
I am working(vb.net03and05) with word documents stored in a sql db and I am
currently bringing them from a byte array into a temp file to pop into word
and make word do its thing as a com object. Is it possible to go straight
from a byte array to document in word instead of a temp file? Also is there
a way to change the save behaviour to notify my app to pickup a binary copy
of the file or stream to save back to the sql db.

Thanks in Advance :-}

Nov 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi

When we automation Word, we are using Word's Object Modal, but the OM's
Documents Open method did not accept a bytearray, it need a filename.
So we need the temp file.

Open method as it applies to the Documents object.

Opens the specified document and adds it to the Documents collection.
Returns a Document object.

Security Avoid using hard-coded passwords in your applications. If a
password is required in a procedure, request the password from the user,
store it in a variable, and then use the variable in your code. For
recommended best practices on how to do this, see Security Notes for
Microsoft Office Solution Developers.

expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
WritePasswordTemplate, Format, Encoding, Visible, OpenConflictDocument,
OpenAndRepair , DocumentDirection, NoEncodingDialog)
expression Required. An expression that returns a Documents object.

FileName Required Variant. The name of the document (paths are accepted).

ConfirmConversions Optional Variant. True to display the Convert File
dialog box if the file isn't in Microsoft Word format.

ReadOnly Optional Variant. True to open the document as read-only. Note
This argument doesn't override the read-only recommended setting on a
saved document. For example, if a document has been saved with read-only
recommended turned on, setting the ReadOnly argument to False will not
cause the file to be opened as read/write.

AddToRecentFiles Optional Variant. True to add the file name to the list
of recently used files at the bottom of the File menu.

PasswordDocument Optional Variant. The password for opening the document.

PasswordTemplate Optional Variant. The password for opening the template.

Revert Optional Variant. Controls what happens if FileName is the name of
an open document. True to discard any unsaved changes to the open document
and reopen the file. False to activate the open document.

WritePasswordDocument Optional Variant. The password for saving changes
to the document.

WritePasswordTemplate Optional Variant. The password for saving changes
to the template.

Format Optional Variant. The file converter to be used to open the
document. Can be one of the following WdOpenFormat constants.

WdOpenFormat can be one of these WdOpenFormat constants.
wdOpenFormatAllWord
wdOpenFormatAuto The default value.
wdOpenFormatDocument
wdOpenFormatEncodedText
wdOpenFormatRTF
wdOpenFormatTemplate
wdOpenFormatText
wdOpenFormatUnicodeText
wdOpenFormatWebPages

To specify an external file format, apply the OpenFormat property to a
FileConverter object to determine the value to use with this argument.

Encoding Optional Variant. The document encoding (code page or character
set) to be used by Microsoft Word when you view the saved document. Can be
any valid MsoEncoding constant. For the list of valid MsoEncoding
constants, see the Object Browser in the Visual Basic Editor. The default
value is the system code page.

Visible Optional Variant. True if the document is opened in a visible
window. The default value is True.

OpenConflictDocument Optional Variant. Specifies whether to open the
conflict file for a document with an offline conflict.

OpenAndRepair Optional Variant. True to repair the document to prevent
document corruption.

DocumentDirection Optional WdDocumentDirection. Indicates the horizontal
flow of text in a document.

WdDocumentDirection can be one of these WdDocumentDirection constants.
wdLeftToRight default
wdRightToLeft

NoEncodingDialog Optional Variant. True to skip displaying the Encoding
dialog box that Word displays if the text encoding cannot be recognized.
The default value is False.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 22 '05 #2

P: n/a
Short answer it can't be done now. Is there intent to do this at some point
with the possibly the next iteration or word?

""Peter Huang" [MSFT]" wrote:
Hi

When we automation Word, we are using Word's Object Modal, but the OM's
Documents Open method did not accept a bytearray, it need a filename.
So we need the temp file.

Open method as it applies to the Documents object.

Opens the specified document and adds it to the Documents collection.
Returns a Document object.

Security Avoid using hard-coded passwords in your applications. If a
password is required in a procedure, request the password from the user,
store it in a variable, and then use the variable in your code. For
recommended best practices on how to do this, see Security Notes for
Microsoft Office Solution Developers.

expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
WritePasswordTemplate, Format, Encoding, Visible, OpenConflictDocument,
OpenAndRepair , DocumentDirection, NoEncodingDialog)
expression Required. An expression that returns a Documents object.

FileName Required Variant. The name of the document (paths are accepted).

ConfirmConversions Optional Variant. True to display the Convert File
dialog box if the file isn't in Microsoft Word format.

ReadOnly Optional Variant. True to open the document as read-only. Note
This argument doesn't override the read-only recommended setting on a
saved document. For example, if a document has been saved with read-only
recommended turned on, setting the ReadOnly argument to False will not
cause the file to be opened as read/write.

AddToRecentFiles Optional Variant. True to add the file name to the list
of recently used files at the bottom of the File menu.

PasswordDocument Optional Variant. The password for opening the document.

PasswordTemplate Optional Variant. The password for opening the template.

Revert Optional Variant. Controls what happens if FileName is the name of
an open document. True to discard any unsaved changes to the open document
and reopen the file. False to activate the open document.

WritePasswordDocument Optional Variant. The password for saving changes
to the document.

WritePasswordTemplate Optional Variant. The password for saving changes
to the template.

Format Optional Variant. The file converter to be used to open the
document. Can be one of the following WdOpenFormat constants.

WdOpenFormat can be one of these WdOpenFormat constants.
wdOpenFormatAllWord
wdOpenFormatAuto The default value.
wdOpenFormatDocument
wdOpenFormatEncodedText
wdOpenFormatRTF
wdOpenFormatTemplate
wdOpenFormatText
wdOpenFormatUnicodeText
wdOpenFormatWebPages

To specify an external file format, apply the OpenFormat property to a
FileConverter object to determine the value to use with this argument.

Encoding Optional Variant. The document encoding (code page or character
set) to be used by Microsoft Word when you view the saved document. Can be
any valid MsoEncoding constant. For the list of valid MsoEncoding
constants, see the Object Browser in the Visual Basic Editor. The default
value is the system code page.

Visible Optional Variant. True if the document is opened in a visible
window. The default value is True.

OpenConflictDocument Optional Variant. Specifies whether to open the
conflict file for a document with an offline conflict.

OpenAndRepair Optional Variant. True to repair the document to prevent
document corruption.

DocumentDirection Optional WdDocumentDirection. Indicates the horizontal
flow of text in a document.

WdDocumentDirection can be one of these WdDocumentDirection constants.
wdLeftToRight default
wdRightToLeft

NoEncodingDialog Optional Variant. True to skip displaying the Encoding
dialog box that Word displays if the text encoding cannot be recognized.
The default value is False.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '05 #3

P: n/a
Hi

So far we can not make sure if the feature will be included in the next
version.
Anyway, thank you for your feedback and you may still try to post the
feedback to the link below.
http://office.microsoft.com/en-us/co...spx?Sitename=0

Thanks!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.