Solved

VB_Excel

Posted on 2003-11-24
8
362 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 65
Reading the Contents of a Directory In Access VBA 5 71
fso.FolderExists("\\server\HiddenFolder$") 4 69
RUNRMTCMD from AS/400 12 47
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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

832 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