Ask Your Question

Macro for gradually revealing contents cell by cell [closed]

asked 2017-02-10 17:05:37 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


Hope someone's can help me with this. I am trying to create a macro that will gradually reveal a previously written list every time I click a button. I hide the text in the cells by changing it to white on white background and what I want the macro to do is to move to a cell below the current and to change the text color to black.

I thought it would be easy to just record a macro with two sub routines and perhaps edit them a bit. But no matter how i do it only one routine works, moving to the cell below - Unless I manually select a cell first.

Does anybody have an answer to why it doesn't work.

Code posted below:

Edited for clarity:

Sub Main

 End Sub

sub Reveal_text
 rem ----------------------------------------------------------------------
 rem define variables dim document as object dim dispatcher as object
 rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoServ("")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())

rem ----------------------------------------------------------------------
dim args2(0) as new
args2(0).Name = "Color"
args2(0).Value = 0

dispatcher.executeDispatch(document, ".uno:Color", "", 0, args2())

end sub
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-08-07 20:13:11.229197

2 Answers

Sort by » oldest newest most voted

answered 2017-02-10 23:05:35 +0200

Lupp gravatar image

updated 2017-02-10 23:08:36 +0200

I would suggest not to set text color and/or background color explicitly, but to use Conditional Formatting to apply (overlay) a "normal" readable cell style to the unveiled cells while veiled cells have a 'Numbers' format that hides every result or direct content.

A Sub providing the information can be assigned to the sheet event 'Selection changed'. Some functions for call by formatting conditions can access this info then.

You may want to study this attachment.

edit flag offensive delete link more


@Lupp Thank You for advice and information. Most welcomed.

Ratslinger gravatar imageRatslinger ( 2017-02-10 23:41:53 +0200 )edit

answered 2017-02-10 18:56:17 +0200

Ratslinger gravatar image

updated 2017-02-10 19:00:30 +0200

This routine will go DOWN one cell and change the text color to BLACK:

Sub Reveal_text
    dim document as  Object
    dim dispatcher as Object
    dim oCurrSel as   Object

    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("")
    dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, Array())
    oCurrSel = ThisComponent.getCurrentSelection()
    oCurrSel.CharColor = 0
End Sub
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-02-10 17:05:37 +0200

Seen: 145 times

Last updated: Feb 10 '17