[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Execute an excel from vb and execute a macro that is in this excel file

Hello, I´m creting a little application to control another excel application.

I have to open a determinate excel file, and I have to pass to a textbox some parameters, after this I will have to execute the event of a button.

I guess that it´s possible, isn´t it¿?
0
1469
Asked:
1469
  • 2
1 Solution
 
bruintjeCommented:
Hello 1469,

this is a great place to start
source: http://www.vbforums.com/showthread.php?postid=2385745#poststop

be sure to add a reference to excel under your projects | references in VB
----------
Dim oXLApp As Excel.Application
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet

'this will open the workbook
  Set oXLApp = New Excel.Application
  Set oXLBook = oXLApp.Workbooks.Open("c:\my folder\my workbook.xls")
  Set oXLSheet = oXLBook.Sheets(1)
  oXLApp.Visible = True
 
'now pass some data to the sheet 1
  oXLSheet.Cells(1, 1) = "hello there" 'cell A1
  oXLSheet.Cells(2, 1) = "hello there" 'cell A2
 
'now execute a macro
  oXLApp.Run "myMacroName" [, "Arg1"][, "Arg2"] 'you can add arguments here or only call the macro by name

----------

hope this helps a bit
bruintje
0
 
1469Author Commented:
I want to pass some text to a textbox that is into a frame
0
 
bruintjeCommented:
a frame, is this a webpage or a vb application?
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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