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
Solved

VB_Excel

Posted on 2003-11-24
8
363 Views
Last Modified: 2010-05-01
Well I need to call an excel sheet from my Visual Basic Application and when the excel sheet opens then it must contain the macros defined for that sheet dynamically.

How do I Do it
0
Comment
Question by:amiteshsinha
  • 4
  • 3
8 Comments
 
LVL 29

Accepted Solution

by:
leonstryker earned 250 total points
ID: 9811653
You need establish a reference to Excel  then

Dim xl as Excel.Application

Set xl = New Excel.Application

With xl
    .Workbooks.Open <path\name.xls>  <-------------- You Excel workbook
    '  So on and so forth
End With

"macros defined for that sheet dynamically."
This you must expand on a bit more, for me to answer the question.

Leon
0
 

Author Comment

by:amiteshsinha
ID: 9811726
Well When I call the excel sheet from my visual basic application then my visual basic application must pass the required code which would then add the code in VBE with a macro name assigned to it.

So everytime an excel sheet is opened from the Visual Basic Application that excel sheet will already have the required code in VBE with an macro name
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9811912
You can just run Excel VBA code from within VB.

Alternatively you can put VBA into an Excel template and drop that template into the default Excel template directory.

Neither of these solutions answer your question but they may be suitable workarounds for your final objective.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:amiteshsinha
ID: 9812226
When I open Excel from visual basic in webbrowser I do not get to see the excel menu's.
It just shows me the excel sheet.
How do i do it
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9812231
As  nmcdermaid you can use a template, but you do not need to place it in the Excel template directory.  You would just need to save it with a .xlt extension.  The templates would already have predefined code in them and any instance of that template would have that code.

Leon
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9812239
You can get to the Excel's IDE by doing Alt+F11 or from the Tools/Macro/Visual Basic Editor

Leon
0
 

Author Comment

by:amiteshsinha
ID: 9814002
How to find active cell when we click on any cell in the excel sheet.
I need to know the column and row value for the cell selected
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9814110
ActiveCell.Row     <---- will return the row number

ActiveCell.Column <---- will return the column number

ActiveCell.address <--- will give you the full address
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

808 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