Solved

Traslate Office Interop function calls to C++ from VB

Posted on 2011-03-18
4
570 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Setup project 6 79
Adding a namespace that doesn't exist for a SSIS Script Transformation 3 59
Issues with C++ Class 19 109
How do I get Window Title of all opened process? 4 39
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

726 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