Problem Insert Ole Object in document

M

Matthias Korte

Hi newsgroup,
i have a problem with inserting a word document as object to another
document.
To do that insert process, we use the InlineShapes.AddOleObject(...) Method.

The Environment is Microsoft Office 2007 Enterprise.

When i do this add process on my developer machine, the document is inserted
as a Picture object.
I can change the size of the object.
When i do the add process on a customer machine, the document is inserted as
a document-object.
When i want to edit the size of the object, the size can't be changed.

On both machines we have the same office version.
I think it's an OLE problem, how can i solve that problem?

Best regards,
Matthias
 
J

Jean-Guy Marcil

Matthias Korte was telling us:
Matthias Korte nous racontait que :
Hi newsgroup,
i have a problem with inserting a word document as object to another
document.
To do that insert process, we use the InlineShapes.AddOleObject(...)
Method.
The Environment is Microsoft Office 2007 Enterprise.

When i do this add process on my developer machine, the document is
inserted as a Picture object.
I can change the size of the object.
When i do the add process on a customer machine, the document is
inserted as a document-object.
When i want to edit the size of the object, the size can't be changed.

On both machines we have the same office version.
I think it's an OLE problem, how can i solve that problem?

Show us the relevant code you are actually using.
 
M

Matthias Korte

Hi Jean,

here is the relevant method, that inserts a OleObject and try to change the
size:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

....
_oRange = _oDocument.Range(ref oStart, ref oEnd);
....

public void insertOleObject(object oDoc, Boolean lPageBreak)
{

object oLink = false;
object oIcon = false;
object oSave = true;
object o1 = Type.Missing;
object o2 = 0;
object oIndex = 0;
IEnumerator oPictures;
Word.InlineShape oPicture;

try
{
_oRange.Collapse(ref _oCollapsEnd);
_oRange = _oRange.InlineShapes.AddOLEObject(ref o1, ref
oDoc, ref oLink, ref oIcon, ref o1, ref o1, ref o1, ref o1).Range;
oPictures =
(IEnumerator)_oRange.InlineShapes.GetEnumerator();
for (int i = 1; i <= _oRange.InlineShapes.Count; i++)
{
oPictures.MoveNext();
oPicture = (Word.InlineShape)oPictures.Current;
oPicture.Width = oPicture.Width * (float)0.63;
oPicture.Height = oPicture.Height * (float)0.63;
}
_oRange.Collapse(ref _oCollapsEnd);

}
catch (Exception e)
{
// do some error handling here
}
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I hope that code snippet helps..

Best regards,
Matthias
 
M

Matthias Korte

Hi,
i created a small test application to demonstrate the problem. (i add the
source code to the topic).
When i run this app it works correct under Microsoft Office 2007. When i run
this app under Office 2003, the size of the OleObject will not be changed.
Are there any changes between 2003 and 2007.

Best regards,
Matthias
 
C

Cindy M.

Hi Matthias,
_oRange = _oRange.InlineShapes.AddOLEObject(ref o1, ref
oDoc, ref oLink, ref oIcon, ref o1, ref o1, ref o1, ref o1).Range;

I'd say your problem is here. You're not specifying a value for that
first parameter (Type.missing), but this is where you should be
giving the OLE Class information, something like "Word.Document.8".

Record a VBA macro when inserting a document as an object, then look
at what values it records for the parameters. You want to use those
same values...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17
2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top