473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Open Excel workbook. VB and VC

k-w
Hi all

In vb I do:
Dim Ex As New Excel.Application
Ex.Workbooks.Open "c:\tmp\Book1.xls"
Similar code in VC doesn't work:
#pragma comment(lib, "ole32.lib")
#import "c:\program files\Microsoft Office\OFFICE11\XL5EN32.OLB"
rename("DialogBox","__AA__")
/* ... */
Excel::ApplicationPtr app(L"Excel.Application");
((Excel::WorkbooksPtr)app->Workbooks())->Open(_variant_t("c:\\tmp\\Book1.xl*s"));

Index is wrong - yes because we didn't open Workbook yet
How to eliminate/fix/bypass this error
Or may be it should be different way to open Excel workbook in VC?
Best regards,
Vasiliy

Jul 24 '06 #1
2 5948
There is a little difference between VC and VC. Refer to some code
snippets here
http://www.fruitfruit.com/vc/activex/excelauto.cpp

Hi all

In vb I do:
Dim Ex As New Excel.Application
Ex.Workbooks.Open "c:\tmp\Book1.xls"
Similar code in VC doesn't work:
#pragma comment(lib, "ole32.lib")
#import "c:\program files\Microsoft Office\OFFICE11\XL5EN32.OLB"
rename("DialogBox","__AA__")
/* ... */
Excel::ApplicationPtr app(L"Excel.Application");
((Excel::WorkbooksPtr)app->Workbooks())->Open(_variant_t("c:\\tmp\\Book1.xl*s"));

Index is wrong - yes because we didn't open Workbook yet
How to eliminate/fix/bypass this error
Or may be it should be different way to open Excel workbook in VC?
Best regards,
Vasiliy
Jul 25 '06 #2
k-w
thank you very much - very helpful

Best regards,
vasiliy

www.fruitfruit.com wrote:
There is a little difference between VC and VC. Refer to some code
snippets here
http://www.fruitfruit.com/vc/activex/excelauto.cpp

Hi all

In vb I do:
Dim Ex As New Excel.Application
Ex.Workbooks.Open "c:\tmp\Book1.xls"
Similar code in VC doesn't work:
#pragma comment(lib, "ole32.lib")
#import "c:\program files\Microsoft Office\OFFICE11\XL5EN32.OLB"
rename("DialogBox","__AA__")
/* ... */
Excel::ApplicationPtr app(L"Excel.Application");
((Excel::WorkbooksPtr)app->Workbooks())->Open(_variant_t("c:\\tmp\\Book1.xl*s"));

Index is wrong - yes because we didn't open Workbook yet
How to eliminate/fix/bypass this error
Or may be it should be different way to open Excel workbook in VC?


Best regards,
Vasiliy
Jul 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Geert-Pieter Hof | last post by:
Hello, My VB 6.0 application read and writes data from and to a MS Excel workbook, using the Microsoft.Jet.OLEDB.4.0 provider. Now I want to protect the Excel workbook with a password, but I...
2
by: Belinda | last post by:
Hello All I want to place a Excel workbook on the web server and create a URL link to it and when the user clicks on it to the URL/vbscript behind it must launch Excel on the client and open the...
1
by: Lize | last post by:
Hi, I'm writing an ASP application to open an excel workbook, then run a macro stored in the excel file, which produces outputs that will be displayed back onto my ASP application. Now the...
3
by: Jennyfer Barco | last post by:
Hello, I have a question, how can I open Microsoft Excel from .NET. I only need to open a new file in Excel and paste some information and set the Microsoft Excel as the enabled aplication, so the...
2
by: Dominic | last post by:
Hi I've done a lot in Excel Automation in prior C# and VB.Net Versions...but I've no chance just to open an Excel Workbook with Visual Studio 2005. I've go always these HRESULT-Failures...:-( ...
3
by: Agnes | last post by:
Dim dsExcelExport As New System.Data.DataSet Dim daExcelExport As New System.Data.SqlClient.SqlDataAdapter Dim Excel As New Excel.Application Dim strExcelFile As String Dim strFileName As...
3
by: pleaseexplaintome_2 | last post by:
using the code below (some parts not included), I create a new excel workbook with spreadheets. I then want to delete a spreadsheet, but a reference remains open and excel stays in task manager...
1
by: trandtun | last post by:
Hello, I use VS2005,Excel2003,WinXP-sp2 and create asp.net web application project to open the excel file. I want to show excel application. If I use visual development server type from...
4
by: omono84 | last post by:
I know that this should be rather simple but i seem to be missing a step to get it to work. and have been unable to find a solution on the net. The aim is that I click on the open button to find...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.