IOpcPartSet::CreatePart method (msopc.h)

Creates a part object that represents a part and adds a pointer to the object's IOpcPart interface to the set.

Syntax

HRESULT CreatePart(
  [in]          IOpcPartUri             *name,
  [in]          LPCWSTR                 contentType,
  [in]          OPC_COMPRESSION_OPTIONS compressionOptions,
  [out, retval] IOpcPart                **part
);

Parameters

[in] name

A pointer to the IOpcPartUri interface of a part URI object that represents the part name of the part.

To create a part URI object (which implements the IOpcPartUri interface) to represent the part name of the part, call the IOpcFactory::CreatePartUri method.

[in] contentType

The media type of part content.

[in] compressionOptions

A value that describes the way to compress the part content of the part.

[out, retval] part

A pointer to the new IOpcPart that represents the part.

This parameter cannot be NULL.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code/value Description
S_OK
The method succeeded.
E_POINTER
The name parameter is NULL.
E_INVALIDARG
The value passed in the compressionOptions parameter is not a valid OPC_COMPRESSION_OPTIONS enumeration value.
OPC_E_DUPLICATE_PART
0x8051000B
A part with the specified part name already exists in the current package.
OPC_E_INVALID_CONTENT_TYPE
0x80510044
A content type does not conform to the rules for a valid media type, specified in RFC 2616: HTTP/1.1 (http://www.w3.org/Protocols/rfc2616/rfc2616.html) and the OPC.
OPC_E_UNEXPECTED_CONTENT_TYPE
0x80510005
Either the content type of a part differed from the expected content type (specified in the OPC, ECMA-376 Part 2), or the part content did not match the part's content type.
Package Consumption error
An HRESULT error code from the Package Consumption Error Group.
Part URI error
An HRESULT error code from the Part URI Error Group.

Remarks

When a part object is created and a pointer to it is added to the set, the part it represents is serialized when the package is serialized.

This method cannot create a part object that represents a Relationships part.

If part content is compressed prior to the creation of the part object, pass the OPC_COMPRESSION_NONE value in the compressionOptions parameter.

Part content that is already compressed will not compress significantly more.

An IOpcPart provides access to the properties of a part. For details about these properties, see the Parts Overview and the IOpcPart topic.

Thread Safety

Packaging objects are not thread-safe.

For more information, see the Getting Started with the Packaging API.

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header msopc.h

See also

ECMA-376 OpenXML

External Resources

Getting Started with the Packaging API

IOpcFactory::CreatePartUri

IOpcPartSet

OPC_COMPRESSION_OPTIONS

Overviews

Packaging API Reference

Packaging API Samples

Packaging Errors

Parts Overview

RFC 2616: HTTP/1.1

Reference