Created attachment 146349 [details] error thisComponent as optional input parameter If oDoc (thisComponent) is optional input parameter for the function, then macro runs good only from Basic Editor and not from Writer. Example is in the attachment.
if you connect a form control with a basic method, you will receive an ActionEvent as parameter. to make it work, change your macro, e.g.: Sub macroBAD(oEvt) oModel = oEvt.Source.Model oDoc = oModel.getParent.getParent.getParent msgbox oModel.Name msgbox oDoc.drawpage.getforms().getbyname("Form").getByName("buttonBAD").name End Sub
Now I also discover it isn't bug :-). Now I'm testing in macro if oDoc IS thisComponent Sub macroBAD(optional oDoc as object) 'after click on button the atribute oDoc is com.sun.star.awt.ActionEvent if IsMissing(oDoc) OR (NOT (oDoc IS thisComponent)) then oDoc=thisComponent 'correct msgbox oDoc.drawpage.getforms().getbyname("Form").getByName("buttonBAD").name 'error after run from document End Sub