Hello. I got a problem with optional argument when I launch a macro from custom toolbar button. From toolbar, like from menu, the argument must be missing. It's OK from custom menu but not from custom toolbar. In case I use toolbar, the argument is always '0'. LibreOffice tested versions : 4.3.7.2 (both OS windows 7 sp1 and Ubuntu 14.04 LTS); 4.4.5.2 (w7); 5.0.2.2 (w7). Exemple (code): « 'Saving a file called as "TestName". Sub Save_Test_File(optional TestName as String) IF isMissing(TestName) THEN TestName = inputbox("Test name, please?") END IF IF TestName="" THEN TestName = "in progress" msgbox("Test Name = " & TestName) '[saving] end sub » If I spell form a custom menu, an inputbox appears, then a message box displays the "Test Name". With a custum toolbar button, a message box directly displays "Test Name = 0". The "patch" I found is spelling through another macro without argument just calling the first. Exemple : « Sub Save_Test_File_Button Save_Test_File() End sub »
Hi, It isn't a "fake" argument, but the key modifier you press while clicking the toolbar button. Try holding CTRL or SHIFT and you'll see it won't be 0. It's a feature AFAIK...
Hi. Ok. It's not always 0. "Test Name = 8192" with CTRL while clicking. "Test Name = 4096" with Shift while clicking. « It's not a bug, it's a feature!» So,I must deal with. Thank you Maxim Monastirsky for your quick answer.