Just spent 2 hours on the forum looking for this ...
Is there a way to write a macro to "save" the spreadsheet and then "refresh range" so after I update my data, I can just click the button and have the range show as updated?
[Solved] A Save and Refresh Range Macro
-
- Posts: 12
- Joined: Tue Jul 24, 2012 6:36 am
[Solved] A Save and Refresh Range Macro
Last edited by PickmansModel on Sun Jul 29, 2012 7:46 pm, edited 1 time in total.
OpenOffice 3.3.0 on Windows 7
Re: A Save and Refresh Range Macro
can you explain better and attach a sample ?
OpenOffice 4.1 on Windows 10
LibreOffice 5.2 on Windows 10
LibreOffice 5.2 on Windows 10
-
- Posts: 12
- Joined: Tue Jul 24, 2012 6:36 am
Re: A Save and Refresh Range Macro
So I have a spreadsheet/database set up to get selected (those rows with an "x" in the prepared and known columns) information from sheet1 and put it on sheet2... that works fine.
It works fine, but when I change the data on sheet1 (like if I "select" different or more rows) I need to save the spreadsheet (CTRL+S) and then select my range of data on sheet2 and then Data>Refresh Range.
I know you can make buttons using Form Controls and assign that button a macro. I'd like to write a macro that saves (CTRL+S) and then Refresh Range, so when I update my data on sheet1, all I need to do I click the button to update sheet2.
Savvy?
It works fine, but when I change the data on sheet1 (like if I "select" different or more rows) I need to save the spreadsheet (CTRL+S) and then select my range of data on sheet2 and then Data>Refresh Range.
I know you can make buttons using Form Controls and assign that button a macro. I'd like to write a macro that saves (CTRL+S) and then Refresh Range, so when I update my data on sheet1, all I need to do I click the button to update sheet2.
Savvy?
- Attachments
-
- ExampleDB.odb
- (2.74 KiB) Downloaded 248 times
-
- Example.ods
- (8.41 KiB) Downloaded 388 times
OpenOffice 3.3.0 on Windows 7
Re: A Save and Refresh Range Macro
I think this macro will do the job. ThisComponent refers to the document that calls the macro
Code: Select all
ThisComponent.store()
oRange = ThisComponent.DatabaseRanges.getByName("Import1")
oRange.refresh()
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 12
- Joined: Tue Jul 24, 2012 6:36 am
Re: A Save and Refresh Range Macro
Nothing happened ... I copied your code then Tools>Macros>Organize Macros>Basic>NewFJCC wrote:I think this macro will do the job. ThisComponent refers to the document that calls the macroCode: Select all
ThisComponent.store() oRange = ThisComponent.DatabaseRanges.getByName("Import1") oRange.refresh()
Then I pasted your code between Sub Main and End Sub... Then I added some "X"s on sheet1 and ran the macro. My range did not refresh. Then I saved first, and ran the macro again... still nothing.
OpenOffice 3.3.0 on Windows 7
Re: A Save and Refresh Range Macro
Works for me. Works for me. I stored the macro in the document so ThisComponent always refers to the intended document.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 12
- Joined: Tue Jul 24, 2012 6:36 am
Re: A Save and Refresh Range Macro
I'm a moron ... I had the Macro Security set too high. Works perfectly. Thanks guys!!!
OpenOffice 3.3.0 on Windows 7