VB studs,
I want to write VBA code that will open an excel sheet chose an entry of the list created on this sheet and also click a button on this sheet. Should be easy, but I can't figure it out.
Thanks in Advance,
VO
Printable View
VB studs,
I want to write VBA code that will open an excel sheet chose an entry of the list created on this sheet and also click a button on this sheet. Should be easy, but I can't figure it out.
Thanks in Advance,
VO
What so you have so far, post your code.
I have no code right now, but I think it should be something like this...
VB Code:
Dim oApp As Excel.Application Dim oWB As Excel.Workbook Dim Sheet As Excel.Worksheet Dim i As Integer Set oApp = CreateObject("Excel.Application") oApp.Visible = True Set Sheet = oWB.Sheets(1) 'Choose the 1st entry in the listbox sheet.listbox.Selected(1) = True 'Run a sub routine on the other sheet sheet.subrountine arguments
You say you want to write VBA code but It sounds like your needing this in VB6?
Either way is fine... Is it different in VBA that it is in VB6?
Thanks,
VO
Either way is fine... Is it different in VBA that it is in VB6?
Thanks,
VO
o.0...is that a new form of double post?
This should get you started in Automating Excel from VB6.
VB Code:
Option Explicit 'Add a reference to MS Excel xx.0 Object Library Private moApp As Excel.Application Private Sub FormLOad() set moapp = New Excel.Application End Sub Private Sub Command1_Click() Dim oWB As Excel.WorkBook Set oWB = moApp.Workbooks.Open("C:\Test.xls") moApp.Visible = True oWB.Sheets(1).Select MsgBox oWB.Sheets(1).Cells(1, 1).Value oWB.Close Set oWB = Nothing moApp.Visible = False End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If TypeName(moApp) <> "Nothing" Then moApp.Quit End If Set moApp = Nothing End Sub