VB_Excel

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
amiteshsinhaAsked:
Who is Participating?
 
leonstrykerCommented:
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
 
amiteshsinhaAuthor Commented:
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
 
nmcdermaidCommented:
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
amiteshsinhaAuthor Commented:
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
 
leonstrykerCommented:
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
 
leonstrykerCommented:
You can get to the Excel's IDE by doing Alt+F11 or from the Tools/Macro/Visual Basic Editor

Leon
0
 
amiteshsinhaAuthor Commented:
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
 
leonstrykerCommented:
ActiveCell.Row     <---- will return the row number

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

ActiveCell.address <--- will give you the full address
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.