Ask Your Question
0

Why can't the compiler find the method getActiveSheet? [closed]

asked 2013-04-13 17:10:29 +0100

Primomh gravatar image

updated 2015-10-30 08:24:13 +0100

Alex Kemp gravatar image

Hello,

On LibreOffice 3.6.2.2 on Linux Mint 14, I try to use

Dim oActiveSheet As Variant
oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()

But when I launch it, the compiler says me that he can find the methode or property getActiveSheet.

How can I correct this?

Thank you

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-30 08:25:26.591822

Comments

Where do you launch your macro? From what? From sheet of workbook or from basic IDE? What component basic get as ThisComponent?

JohnSUN gravatar imageJohnSUN ( 2013-04-13 19:40:30 +0100 )edit

After some test, the command works. I just comment and uncomment "Option Explicit". Thanks you for your help

Primomh gravatar imagePrimomh ( 2013-04-14 20:34:08 +0100 )edit

Miracle on the level of shamanism :-)

JohnSUN gravatar imageJohnSUN ( 2013-04-14 20:41:32 +0100 )edit

@Primomh -- could you please turn your comment into an Answer so we could use it to resolve this question? (As @JohnSUN notes, the solution does seem a bit like black magic, but if that's what fixed it... :-)

Thanks!

qubit gravatar imagequbit ( 2013-04-14 20:44:54 +0100 )edit

3 Answers

Sort by » oldest newest most voted
0

answered 2013-04-14 22:19:55 +0100

qubit gravatar image

(Comment -> Answer for resolution)

Primomh notes:

After some test, the command works. I just comment and uncomment "Option Explicit". Thanks you for your help

edit flag offensive delete link more
0

answered 2013-04-13 20:01:31 +0100

JohnSUN gravatar image

Please, try this code:

Sub testDocType
Dim oDoc
Dim docType$
Dim oSheet
    oDoc = ThisComponent
    GlobalScope.BasicLibraries.LoadLibrary("Tools")
    docType = GetDocumentType(oDoc) 
    print "Now 'ThisComponent' is '"+docType+"'"
    If docType<>"scalc" Then Exit Sub
    oSheet = oDoc.getCurrentController().getActiveSheet()
    print "Name of Active Sheet is '"+oSheet.getName()+"'"
End Sub
edit flag offensive delete link more
0

answered 2013-04-14 21:28:36 +0100

Primomh gravatar image

See comment of the first post for the answer

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-13 17:10:29 +0100

Seen: 851 times

Last updated: Apr 14 '13