COleDispatchException. SCODE: 800a16ca

W

WishfulDoctor

Hi,

If this is not the right newsgroup - please direct me to the right one. The
question is about an error I get (COleDispatchException. SCODE: 800a16ca)
trying to use Word automation from a C++ program. This is aprogram that is
in use for quite some time without any errors & I have the error happening
in a computer that is XP Spanish and Office Spanish.
I have narrowed the source down to an area and have a strong guess as to the
offending area - I think it is the use of "Heading", and "Normal" for styles
where the user's machine probably have Spanish equivalents and hence the
error. If this is the case, How can I get the equivalent - is there any way
to do this in other language settings?

CString sStl;

sStl.Format("Heading %d",iLvl);

range.SetStyle(COleVariant((LPCTSTR)sStl)); //range is set earlier in the
code

range.SetText(p->m_text);

range.InsertAfter("\r\n");

range.Collapse(COleVariant((long)0));

range.SetStyle(COleVariant("Normal"));
 
P

Peter Huang [MSFT]

Hi

Based on my knowledge, the Style is a property of the Range object.
Commonly we should set it use the Word buildin constant.

Style property as it applies to the Find, HeadingStyle, Paragraph,
ParagraphFormat, Paragraphs, Range, Replacement, Selection, and Table
objects.

Returns or sets the style for the specified object. To set this property,
specify the local name of the style, an integer, a WdBuiltinStyle constant,
or an object that represents the style. For a list of valid constants,
consult the Microsoft Visual Basic Object Browser. Read/write Variant.

expression.Style
expression Required. An expression that returns one of the above objects.

Remarks
When you return the style for a range that includes more than one style,
only the first character or paragraph style is returned.


Here are I got from Microsoft Visual Basic Object Browser.
Const wdStyleNormal = -1 (&HFFFFFFFF)
Const wdStyleHeading1 = -2 (&HFFFFFFFE)
Const wdStyleHeading2 = -3 (&HFFFFFFFD)
....
You may have a try.

If you do wants to use the string type, I think you may have to use the vba
code to dump the style.
e.g.
Sub Test()
Debug.Print ThisDocument.Content.Style
End Sub




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.
 
W

WishfulDoctor

Thanks for the reply Peter.

Let me make sure that I understand - instead of using a variant created
from the string "Heading1", I would use a variant created from the
number -2. Since these constants use numbers, they should be the same in
all languages.

I will try it and let you know if it works in English.
 
P

Peter Huang [MSFT]

Hi

Yes, the constant is defined in the Word's Object Modal across multiple
language version.
If you still have any concern, please feel free to post here.

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.
 
W

WishfulDoctor

Thanks Peter,

It worked in the English language version - am waiting to hear from the
customer with the Spansih language version
 
P

Peter Huang [MSFT]

Hi

Ok, if you still have any concern, please feel free to post here.

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.
 

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