?
Solved

Traslate Office Interop function calls to C++ from VB

Posted on 2011-03-18
4
Medium Priority
?
572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

764 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