I'm sorry but after three days I Give Up... So I'm asking what should be a very simple question but every example I find opens an Excel file or opens a read Only version of the same file, to do something where as in my case the file has already been opened from another macro using the code below, I just can't seem to figure how to adapt it for a file already open??
I'm also trying to figure out how to move excel to the active window from within the code? I would really appreciate any help
Dim oApp As Object
Dim x As Variant
Dim sPath As String
Dim oExcel As Excel.Application
Dim oWB As Workbook
Dim oSheet As String
sPath = "E:\Special Folders\WWWRoot\temp.xlsx"
oSheet = "--Keywording--"
On Error Resume Next
Set oExcel = New Excel.Application
Set oWB = oExcel.Workbooks.Open(sPath)
oExcel.Visible = True
Sheets(oSheet).Select
Range("A1:G1000").Clear
Range("A1").Select
Sheets(oSheet).Cells(1, 1).Select
Sheets(oSheet).PasteSpecial (xlPasteAll)
Range("A1").Select
set oExcel = GetObject(, "Excel.Application")orSet oExcel = GetObject("Book2").ApplicationRead this for more details:support.microsoft.com/en-us/help/288902/… - cyboashuoWBbetween your macros.) - YowE3KApplication.Workbookscollection. You canActivateit, likeoExcel.Workbooks("MyWorkbook.xlsx").Activate. However, it seems like you confuse the Excel application, an Excel workbook and a workbook's worksheet.oExcel.Sheets(oSheet)can never work and neither canGetObject(oSheet).Application. Consider working withoutActivateand withoutSelect.oSheet.Range("A1:G1000").ClearContentswill work provided oSheet is set as a worksheet of an open workbook. - Variatus