473,606 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open Excel workbook. VB and VC

k-w
Hi all

In vb I do:
Dim Ex As New Excel.Applicati on
Ex.Workbooks.Op en "c:\tmp\Book1.x ls"
Similar code in VC doesn't work:
#pragma comment(lib, "ole32.lib" )
#import "c:\program files\Microsoft Office\OFFICE11 \XL5EN32.OLB"
rename("DialogB ox","__AA__")
/* ... */
Excel::Applicat ionPtr app(L"Excel.App lication");
((Excel::Workbo oksPtr)app->Workbooks())->Open(_variant_ t("c:\\tmp\\Boo k1.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 5957
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.Applicati on
Ex.Workbooks.Op en "c:\tmp\Book1.x ls"
Similar code in VC doesn't work:
#pragma comment(lib, "ole32.lib" )
#import "c:\program files\Microsoft Office\OFFICE11 \XL5EN32.OLB"
rename("DialogB ox","__AA__")
/* ... */
Excel::Applicat ionPtr app(L"Excel.App lication");
((Excel::Workbo oksPtr)app->Workbooks())->Open(_variant_ t("c:\\tmp\\Boo k1.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.Applicati on
Ex.Workbooks.Op en "c:\tmp\Book1.x ls"
Similar code in VC doesn't work:
#pragma comment(lib, "ole32.lib" )
#import "c:\program files\Microsoft Office\OFFICE11 \XL5EN32.OLB"
rename("DialogB ox","__AA__")
/* ... */
Excel::Applicat ionPtr app(L"Excel.App lication");
((Excel::Workbo oksPtr)app->Workbooks())->Open(_variant_ t("c:\\tmp\\Boo k1.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
25250
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 figured out that it is not possible to open the workbook for data access with ADO (http://support.microsoft.com/?KBID=211378). Is there another way to use a password protected Excel workbook in my
2
2292
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 URL linked Excel workbook automatically. Can you please share the code HTMl & VB script snippet that can do this.
1
6375
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 problem I'm having is whenever I try to open a workbook (of any format, i.e. 97/2000, 95, or xp, and of any size, and with or without macros), excel just hangs forever, and if I killed the excel application in task manager, my asp application will...
3
7418
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 user can continue working in Excel and he'll save the information I pasted. I tried this but doesn't open Excel at all, but it does save the file c:\test.xls with the value "This is column B row 2" in colum B and row 2: Dim xlApp As...
2
2628
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...:-( Thanks for your help... Here's one of the code trials:
3
2072
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 String dsExcelExport.Clear() daExcelExport.SelectCommand = New SqlCommand daExcelExport.SelectCommand.Connection =
3
4827
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 when the code highlighted below is used. can someone help me identify what object remains open and how to release that reference? thanks using Excel = Microsoft.Office.Interop.Excel;
1
1662
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 project propertes,I get it. But if I use IIS Web server type ,I can't get.
4
4030
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 and open an unknown workbook that contains the data that I need to imput into my current workbook, once the unknown workbook is opened it should automatically select my range (number of columns known, but number of rows unknown- the number of rows...
0
8036
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7978
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8448
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8317
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6796
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3948
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.