Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Get right Excel application

Hi !
In Excel, when 2 differents Excel.Application, there's an error with these
lines.
Set oExcel = GetObject(, "Excel.Application")
Set oWb = oExcel.ThisWorkbook 'ERROR 1004..
Set oXlRng = oWb.Sheets(T(iTab).SheetName).Range("TableOutput")
I'm wondering if I could just say:
Set oXlRng = ThisWorkbook.Sheets(T(iTab).SheetName).Range("Tabl eOutput")
and defined oXlRng as a Range. Should I declare Excel.Range if the word
library are open into Excel?
Thanks!
Alex

--
Alex St-Pierre
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Get right Excel application

Set oWb = oExcel.ThisWorkbook 'ERROR 1004

I think you want:

Set oWb = oExcel.ActiveWorkbook

--
Jim
"Alex St-Pierre" wrote in message
...
| Hi !
| In Excel, when 2 differents Excel.Application, there's an error with these
| lines.
| Set oExcel = GetObject(, "Excel.Application")
| Set oWb = oExcel.ThisWorkbook 'ERROR 1004..
| Set oXlRng = oWb.Sheets(T(iTab).SheetName).Range("TableOutput")
| I'm wondering if I could just say:
| Set oXlRng =
ThisWorkbook.Sheets(T(iTab).SheetName).Range("Tabl eOutput")
| and defined oXlRng as a Range. Should I declare Excel.Range if the word
| library are open into Excel?
| Thanks!
| Alex
|
| --
| Alex St-Pierre


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Get right Excel application

Thisworkbook would only be applicable if the code is being run from the
workbook you want to refer to.

T(iTab).SheetName

seems a bit strange. What is T. At least through Excel 2003, I don't
believe there is any object that has a sheetname property.

--
Regards,
Tom Ogilvy




"Alex St-Pierre" wrote:

Hi !
In Excel, when 2 differents Excel.Application, there's an error with these
lines.
Set oExcel = GetObject(, "Excel.Application")
Set oWb = oExcel.ThisWorkbook 'ERROR 1004..
Set oXlRng = oWb.Sheets(T(iTab).SheetName).Range("TableOutput")
I'm wondering if I could just say:
Set oXlRng = ThisWorkbook.Sheets(T(iTab).SheetName).Range("Tabl eOutput")
and defined oXlRng as a Range. Should I declare Excel.Range if the word
library are open into Excel?
Thanks!
Alex

--
Alex St-Pierre

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Get right Excel application

Hi Tom
T is a custom variable as decribe below. I load all the information in T
vector when the macro start. So, I can refer it at any time. "Thisworkbook"
is correct since the macro code is always inside the right excel file. I'm
wondering if I need to use object programation. I have modify the program to
say:
Dim oXlRng As Range
Set oXlRng = ThisWorkbook.Sheets(T(iTab).SheetName).Range("Tabl eOutput")
... (program) oXlRng.Copy, oXlRng.Cells(1,2) = ..., etc.
Set oXlRng = Nothing

T is defined as:
Public Type TableType
Count As Integer 'For i = 1 to T(1).Count
Type As String 'Short Name
CodeName As String 'Long Name
SheetName As String
StandardSheetName As String
StandardTitle1 As String
Title1 As String
Title2 As String
Exist As Boolean
Link As Boolean 'Used inside report
Export As Boolean 'Checked item
End Type

Public T(14) As TableType

--
Alex St-Pierre


"Tom Ogilvy" wrote:

Thisworkbook would only be applicable if the code is being run from the
workbook you want to refer to.

T(iTab).SheetName

seems a bit strange. What is T. At least through Excel 2003, I don't
believe there is any object that has a sheetname property.

--
Regards,
Tom Ogilvy




"Alex St-Pierre" wrote:

Hi !
In Excel, when 2 differents Excel.Application, there's an error with these
lines.
Set oExcel = GetObject(, "Excel.Application")
Set oWb = oExcel.ThisWorkbook 'ERROR 1004..
Set oXlRng = oWb.Sheets(T(iTab).SheetName).Range("TableOutput")
I'm wondering if I could just say:
Set oXlRng = ThisWorkbook.Sheets(T(iTab).SheetName).Range("Tabl eOutput")
and defined oXlRng as a Range. Should I declare Excel.Range if the word
library are open into Excel?
Thanks!
Alex

--
Alex St-Pierre

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.Index & Application.Match Antonio Excel Programming 8 February 5th 07 02:13 PM
difference application.quit & application.close Pierre via OfficeKB.com[_2_] Excel Programming 4 November 8th 05 07:55 PM
Application.GetOpenFilename vs Application.Dialogs(xlDialogsOpen) Paul Martin Excel Programming 5 August 5th 05 04:44 PM
Replace application.RTD property by Application.RTDServers collect John.Greenan Excel Programming 1 July 7th 05 02:05 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"