I could open another workbook in separate window by using two methods
TheEmu_Path = "excel.exe " & ThisWorkbook.Path & "\" & "myexcel.xlsx"
call Shell(TheEmu_Path, 3)
or
Set oExcel = New Excel.Application
oExcel.Workbooks.Open Filename:=TheEmu_Path & "myexcel.xlsx"
The first method I could Open but don't know how to set a reference for the open workbook The second I could reference when opening the workbook but later for any later process I don't know how to reference that separately-opened worksheet
Set oExcel = ??
Set oWB = oExcel.Workbooks("myexcel.xlsx")
Set oWS = oWB.Sheets("F1")
How can I set the reference for oExcel (the already separately opened workbook)?
After creating and opening, later I want to change value in that open separately workbook in new button command
Set oExcel = CreateObject("Excel.Application")
Set oWB = oExcel.Workbooks("myexcel.xlsx")
Set oWS = oWB.Sheets("1")
oWS.Cells(1, 1) = 55
I have a mistake in line two as I believe that I still haven't referenced oExcel correctly.
Comment on David revision
Impressive, thanks a lot.
It works perfectly with very little addition, oExcel will be considered as workbook directly - great!
Dim oExcel As Object 'or Dim oExcel As Workbook
Dim oWS As Excel.Worksheet 'or Dim oWS As Worksheet
Set oExcel = GetObject(ThisWorkbook.Path & "\" & "myexcel.xlsx").Application
'or Set oExcel = GetObject(ThisWorkbook.Path & "\" & "myexcel.xlsx")
Set oWS = oExcel.Sheets("1")
oWS.Cells(1, 1) = 4
This is exciting and encouraging to ask other question as I have my file crashes when using UpdateRemoteReferences that result in #na values.