Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

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
0
amiteshsinha
Asked:
amiteshsinha
  • 4
  • 3
1 Solution
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now