Solved

Traslate Office Interop function calls to C++ from VB

Posted on 2011-03-18
4
561 Views
Last Modified: 2012-05-11
Code for (c++) samples for Microsoft Office Interop use are rare and hard to find.  Mostly I translate them from VB to C++ I have having a real problem compiling with one of them.

 . A vb command that works in other apps that I wrote is  
     Dim formatDOC As Object = Word.WdSaveFormat.wdFormatDocument

I have translated it to
Microsoft::Office::Interop::Word::WdSaveFormat*    formatRTF = new   Microsoft::Office::Interop::Word::WdSaveFormat::wdFormatDocument    ;
or simply (both should work)
Word::WdSaveFormat* formatR = new Word::WdSaveFormat::wdFormatDocument;
These line bring the error message -
error C2061: syntax error : identifier 'wdFormatDocument'
I have checked spelling a dozen times.

I have been unable to find any reports of this being turned in as a bug.
Thanks for any insight into this issue.      
0
Comment
Question by:jkcompute
  • 3
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35165497
wdFormatDocument is an enumeration (integer, basically). It doesn't make sense to me to call "new" for an integer. Perhaps that has something to do with it?
0
 

Author Comment

by:jkcompute
ID: 35183627


When I take out the "new"
Word::WdSaveFormat* formatR = new Word::WdSaveFormat::wdFormatDocument;
I get a type mismatch

 cannot convert from 'Microsoft::Office::Interop::Word::WdSaveFormat' to 'Microsoft::Office::Interop::Word::WdSaveFormat __gc *'  
Managed variables are new to me so I am unable to rectify it.

I tried setting the variable that you would put in if you use the comand in Word. Hoping that Microsfot would cast it for me.
Word::WdSaveFormat* formatR = 1;

error C2440: 'initializing' : cannot convert from 'int' to 'Microsoft::Office::Interop::Word::WdSaveFormat __gc *'
or with
Word::WdSaveFormat* formatR = __gc 1;

error C3150: 'constant' : '__gc' can only be applied to a class, struct, interface, array or pointer

any help?
0
 

Accepted Solution

by:
jkcompute earned 0 total points
ID: 36302902
There seems to be no valid solution.  I bought aspose 3rd party library to solve it.
0
 

Author Closing Comment

by:jkcompute
ID: 36327276
Aspose is very expensive, but surely my time is worth something
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now