Re: Triggering an Excel Sub from Word

Tech-Archive recommends: Speed Up your PC by fixing your registry



Have you moved the "logob" routine to ThisWorkbook codemodule ?

Krgrds,
Perry


"James" <anonymous@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1cd401c53987$1d1598d0$a401280a@xxxxxxxxxx
> HI Again,
>
> My ThisWorkbook is called "RDSTemplate"
>
> I tried moving the sub to the code directly associated with
> this .xls ***.
>
> The code I'm trying looks like this:
> Dim oExcel As Excel.Application
> Dim eWB As Excel.WorkBook
> Set oExcel = GetObject(, "Excel.Application")
> If oExcel Is Nothing Then
> MsgBox "Excel is Not Running"
> ElseIf oExcel.Workbooks.Count = 0 Then
> MsgBox "You have no Excel WorkBooks Open"
> Exit Sub
> Else
> Set eWB = oExcel.Workbooks("Basictemplate.xls")
> If eWB Is Nothing Then
> Else ' Only One Work Book
> eWB.login
> End If
> End If
>
> When it gets to the eWB.logob which is a Public Sub I get
> the error message: Object doesn't support this property or
> method (Error 438).
>
> What am I missing here?
>
> In addition if BasicTemplate is an xla will this affect the
> call?
>
> Also if I want to keep the code in a module (e.g. MyCode)
> how would I then reference the code in that Excel module
> from Word?
>
> Thanks Again for Your Help
> >-----Original Message-----
> >> Is it posible to trigger a Sub in Excel while in Word? I've
> >> set the Sub to Public in the Excel.xla and tried various
> >> referencing methods.
> >
> >Yep, sure is.
> >
> >Place the routine you'd like to run from Word in
> ThisWorkBook code module in
> >Excel.
> >Grant it a public scope.
> >
> >Call it in Word using following simple statement:
> >xlMyWorkbook.MyRoutine
> >(xlMyWorkbook is a valid/instantiated Excel workbook
> object, and MyRoutine
> >as yr routine)
> >Note: you can even add parameters to yr routine in Excel
> and pass values
> >from Word.
> >
> >Actually, the above considers xlMyWorkbook to be a regular
> object.
> >ThisWorkbook code module
> >is nothing more than the Classmodule belonging to the
> Excel workbook object.
> >
> >Krgrds,
> >Perry
> >
> >"James" <anonymous@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >news:175801c538d1$6e8b2420$a401280a@xxxxxxxxxx
> >> HI,
> >>
> >> I have an Excel.xla associated with an Excel document. This
> >> xla has a lot of code written to move data from the Excel
> >> *** to the Word document.
> >>
> >> While in the Word document I want to be able to refresh the
> >> data. Instead of rewriting all the code that already works
> >> on the Excel side I want to trigger the Subs to do the work
> >> as if it were being done from the Excel ***.
> >>
> >> I have tried various methods but that all give me the error
> >> message: "Object Variable or With block variable not set"
> >>
> >> Is it posible to trigger a Sub in Excel while in Word? I've
> >> set the Sub to Public in the Excel.xla and tried various
> >> referencing methods.
> >>
> >> Thanks in Advance
> >> James
> >
> >
> >.
> >


.


Quantcast