Solved

Traslate Office Interop function calls to C++ from VB

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VS2015 compilation and missing DLLs 9 148
object oriented programming on screen browser tutorial lesson 2 81
Convert money to nchar 4 62
designing in object programming 12 80
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

831 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