Free Microsoft Excel 2013 Quick Reference

Office Automation Using Visual C++

Office Automation Using Visual C++

You can even use all of the Microsoft Excel charting ... often not recommended because of reference- counting ... the client application's calls to the member functions of ...

Post your answer or comment

comments powered by Disqus

Related Results

Is there a way to unload the loaded XLL file in Excel?

Hi all,

I am debugging XLL link library using Visual C++. Everytime I rebuild
the XLL, I have to close the whole Excel program and relaunch the
Excel program again,

and then load in the newly generated XLL library again...

This is tedious...

I am looking for a way to unload XLL (already loaded) from within
EXCEL program...

Any thoughts?

(I find just close the currently active worksheet doesn't get the XLL

I am writing Excel automation using Visual basic 6.

The application is supposed to read the excel file created by the
Office 2003 version. I also have Office 2003 on my machine so I set my
reference to "Microsoft Excel 11.0 Object Library"

Now when I try to run the program on the computer that doesn't have
Office 2003 but has Office 2000, it crashed.

Can you let me know how to handle this problem.

I do have the error handling section to display the error but it seems
that the program try to execute but got Error "An exception "Unhandled
Win 32 Exception" has occured in Program.exe"

I would like to check if the excel on the machine is not version 2003
and just abort the program without crashing.

Can anyone help with the sample of source code to determine the version
of Excel in the computer?


Does anyone know where any material is on how to create .xll files for Excel
2003 using visual C++ 2005 express? I am having trouble with the files
xlcall.h and xlcall.lib from the 97 excel sdk - they won't compile. Are
there newer versions of these files available somewhere? Thanks.

I am writing a Visual C++ 6.0 client which need to launch Excel and
display some data using Excel COM automation interface. How can I
programmatically set the column width of a particular column (e.g.
column 3) in Excel?

I can easily achieve this in VB as follow:

sheet.Columns(3).ColumnWidth = 40

But I cannot do this in C++ because the method

LPDISPATCH _Worksheet::GetColumns()

does not take any argument. I believe this method return a Range

How can I set the width of column 3 using C++?


Can any body tell me is it possible to write office
automation application which will run for any version of
Microsoft Office. To be specific, at any time the machine
will have only one of all the available versions of
microsoft office, it can be 97, or 2000 or XP any one of
them. Now, is it possible that sigle application will work
for all this versions, I don't want to use any extensive

Hope i will get an answere from any of you chaps.. very


Excel 2003 c++ automation problem.

hello everyone

Im trying to do excel 2003 automation and I am using visual c++ 2005.

I inserted excel type library using class wizard and it generated
workbooks.h file for me but i got following problem.

In workbooks.h generated by class wizard, the following definitions returns
error saying "Parameter" is undefined. Is "Parameter" type defined somewhere
and do I have to import that definition from some where? Or do I need to
replace "Parameter" with something?

Also I am new to this and have no idea how to find information about how to
use these type library methods, like what each parameters are supposed to
mean. I looked up workbooks.add method in VBA help in excel2003 but its
explanation seems to be wrong (old?). it tells that add method has only one
parameter but the code below has 3 parameters.

How am I supposed to find information for excel 2003 methods and not older
excel library definitions? Also what is the general approach to learn how to
look up things and be able to figure stuff out yourself? where do i start,

//STDMETHOD(Add)(LPCTSTR Name, VARIANT& iDataType, Parameter * * RHS)
// HRESULT result;
// InvokeHelper(0xb5, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms,
Name, &iDataType, RHS);
// return result;

//STDMETHOD(Item)(VARIANT& Index, Parameter * * RHS)
// HRESULT result;
// static BYTE parms[] = VTS_VARIANT VTS_PDISPATCH ;
// InvokeHelper(0xaa, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms,
&Index, RHS);
// return result;

//Parameter get__Default(VARIANT& Index)
// Parameter result;
// static BYTE parms[] = VTS_VARIANT ;
// InvokeHelper(0x0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result,
parms, &Index);
// return result;

Programming Microsoft Word 2002 and Excel 2002 with Microsoft Visual C#

Learn about COM interoperability between Microsoft C# and large, complex COM servers. This article shows how to prepare the Office XP COM objects and how to use them in a C# program.

I writing a sw application with Visual C++ to read/write data to excel file.
I have found an example @ the MSDN on how to create a new excel file
( using
automation method.

My question is how do I save/open an excel file using automation method.

Thanks, WL


In order to run Excel 2003 - Office System Project with C#. All assemblies
(.DLL) use by the project must be set to full trust.

To do it manually, you right click on .NET Configuration 1.1-->Runtime
Security Policy and select "Trust an Assembly".

How can I automate this process?


John Yung

...and exporting results from Visual C++ 2005 (VC++) to Excel. How does one do this? I want to use VC++ as the main calculation/simulation engine, as it is rumored to execute code ~15x faster than an equivalent algorithm coded/executed in Excel VBA.

I'm not too sure about the interfacing part though, i.e. importing input data from Excel to VC++, and subsequently re-exporting results from VC++ back to Excel. Would anyone have sample code showing how such interfacing is done? I think I should be able to extend/customize your sample interfacing code for my specific needs.

A million thanks in advance... and apologies if this question concerning VC++ does not belong here; I wasn't sure of where else to turn to for help.

- om


I have problem with the Office automation security settings.

I have code that processes several PowerPoint presentations. I open the each
of the presentations read-only with no window and do some processing on

But whenever a presentation with macros is processed and the macro's prompt
shows, if I choose "Disable macros" the whole processing presentation loop
dies. It's almost like clicking on the End button in IDE.

If I choose "Enable macros" in the presention currently being processed it
works like a charm....

It seems that "Disable macros" also disable my ppa macros....

I have tried shifting the automation security with no success. Using Office
2003 SP2. I know this isn't a specific Excel problem but maybe you have an
answer this as well.

Thanks in advance.


I am automating an excel workbook with Visual C++, with many sheets,
updating cells frequently, and the client (person, not excel client ;0)
)requests this is done 'visually' so the operator can see the worksheet
changing, the cells updating (why, I don't know, it happens that fast).
but....if the user clicks on a cell and selects it, my code bombs out.
It runs fine as long as the user leaves excel well alone.

Is this common? Is this down to my naff code? Any ideas what I can




I'm trying to do some office automation using VSTO 2005. I've verified that
..Net Programmability Support is installed for every MS Office application
and Microsoft Forms 2.0 .Net Programmability Support is also installed under
Office Tools through Office Setup. I've then installed VSTO 2005 (vstor.exe,
After installing everything and doing a reboot, I'm not getting an Office
node under Visual C# with any of the office templates in Visual Studio 2005
(Microsoft Visual Studio 2005 Version 8.0.50727 RTM.050727-4200) when
attempting to create an new project.

I've also attempted to look for the VSTO Dll's
(Microsoft.Office.Tools.Excel.dll, Microsoft.Office.Tools.Word.dll, etc..)
in C:Program FilesCommon FilesMicrosoft SharedVSTO8.0 to add reference
inside my projects and there not there.. All I see are the
Microsoft.Office.Tools.Excel.xml and Microsoft.Office.Tools.Word.xml docs
that have comments for all the methods that are useable from these Dll's.

If any one could shed any light on this, it would be greatly appreciated...

Thanks in advance,

Software Engineer

Hello. I am trying to create .xll files in visual c++ 2005 express to make
some custom functions for excel. I considered doing this in VBA, but I
already have C code which does the things I want to do, so I thought an .xll
file might be the way to go. I was wondering where I could more information
about this process. In particular, the .xll files used to require xlcall.h
and and xlcall32.lib from the excel 97 sdk. However, those files don't seem
to be compatible with visual studio 2005, and I wasn't sure where to find the
equivalent files (or if there were equivalent files) which were compatible
the with visual c++ 2005 express edition. Thank you.

Using Visual Basic to Exit Windows From Within Excel

The Declare, Call and Register Functions listed in the following macro are very sensitive. ... You can type lines that contain this character as one logical line or you can divide the ...

How to use Visual Basic for Applications (VBA) to change UserForms in ...
How to use Visual Basic for Applications (VBA) to change UserForms in Excel 2003, Excel 2002, and Excel 2000 ... Run-time errors using UserForms collection


I have been trying to add a dymanic formula to a cell using visual
basic and I am running into a little difficulty. Any assistance would
be appreciated.

I attempted using the following code. The problem line is marked with
the words "Problem Line" at the end.

Thank you in advance.

--Ian Web

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Phone Numbers")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for Last Name
If Trim(Me.Txt_Last_Name.Value) = "" Then
MsgBox "Please enter an Employee Last Name"
Exit Sub
End If

'check for First Name
If Trim(Me.Txt_First_Name.Value) = "" Then
MsgBox "Please enter an Employee First Name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.Txt_Last_Name.Value
ws.Cells(iRow, 2).Value = Me.Txt_First_Name.Value
ws.Cells(iRow, 3).Value = "=CONCATENATE(A"&iRow&","", "",B"&iRow&")"

I want to compute the cross products of two vectors using visual basic

I have an excel spreadsheet and call a C++ program from a VBA macro using
the command below. (I am not using visual C++ but a command line driven
version, Borland C++ compiler)

retval = Shell ("c:optionsoptions1.exe", vbNormalFocus)

What I want to be able to do is to pass some of the values in my excel
spreadhseet to the C++ program when calling it. There are 5
variables(spreadsheet cells) whose numerical values I want to pass across to
the program.

Once the C++ program has run I want to put a value that it caluculates in to
a cell in my excel spreadsheet.

Any help much appreciated please.

Many thanks

I am trying to change the color of a Series Collection using visual basic. I
have tried things like "Chart(1).SeriesCollection(2).Points.Interior.Colo r =
3" among many others, if you could give me any help I would appreciate it.


HOWTO: Build an Add-in (XLL) for Excel Using Visual C++:;en-us;Q178474

HOWTO: Install an Excel Add-In (XLA or XLL) with Automation:;en-us;Q280290

First off - I'm new to this forum.

Using microsoft cube which I believe comes off of an OLAP server a pivot table is created. In order to create a report is there a way to use visual basic coding to switch what is shown in the pivot table.

I would be happy to provide more details....



There tend to be some questions/problems in the E-Mail and Word-forum which following good articles may be of help:

OFF97: Microsoft Office 97 Automation Help File Available

OFF2000: Microsoft Office 2000 Automation Help File Available

OFFXP: Microsoft Office XP Automation Help File Available

HOWTO: Improving the Performance of Office Automation Code

INFO: Office Automation When Multiple Versions of Office Are Installed

INFO: Writing Automation Clients for Multiple Office Versions

XL2002: How to Select Ranges Using Visual Basic for Applications (Novice Examples)

No luck finding an answer? You could always try Google.