Solved

VB_Excel

Posted on 2003-11-24
8
360 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:amiteshsinha
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now