RE: Get right Excel application

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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("TableOutput")
... (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("TableOutput")
and defined oXlRng as a Range. Should I declare Excel.Range if the word
library are open into Excel?
Thanks!
Alex

--
Alex St-Pierre
.



Relevant Pages

  • Labels in Formulas requires manual refresh?
    ... I use Labels in Formulas extensively. ... (Excel 2003 11.5612.5606) ... and then use whatever text string I've placed at the top of a column ... of data to refer to it. ...
    (microsoft.public.excel)
  • Re: Autofill column values in formulas
    ... simplest formula you can that refers to any cell. ... formula should refer to cell. ... If my formula that builds that string looks like it's the correct formula, ... Excel will see the results as those nice straight-forward formulas. ...
    (microsoft.public.excel.misc)
  • Re: Need help with SeriesCollection Object Please !
    ... Well Peter your explanation of my questions make sense and are sound answers. ... You seem very experienced with Excel and VBA:) ... Function GetSourceSheet(sFmla As String, sWSname, sFile As String) As ... ran my code on certain other charts sometimes it would return ...
    (microsoft.public.excel.programming)
  • Re: You have to put the URL of the webpage in the macro.
    ... I need your help to update Excel Data in Web Page. ... Function ZipPlusFour(sAdd1 As String, _ ... Dim sResult As String ... Take the html text and put it in a file called ...
    (microsoft.public.excel.programming)
  • Re: Format Excel - Object required error
    ... tell excel to autofit the columns. ... Public Sub FormatXLReport(strPath As String, ... Dim blnExcelExists As Boolean ... Private Const SW_SHOWNORMAL = 1 ...
    (microsoft.public.access.modulesdaovba)