# PostMessage API, '.uno:StyleApply'

**URL:** <https://forum.collaboraonline.com/t/postmessage-api-uno-styleapply/2144>\
**Category:** User Support\
**Created:** [October 31, 2023, 11:23pm UTC](https://forum.collaboraonline.com/t/postmessage-api-uno-styleapply/2144 "2023-10-31T23:23:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sidewaysglance](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/sidewaysglance/32/790_2.png) [@sidewaysglance](https://forum.collaboraonline.com/u/sidewaysglance)\
**Post date:** [October 31, 2023, 11:23pm UTC](https://forum.collaboraonline.com/t/postmessage-api-uno-styleapply/2144/1 "2023-10-31T23:23:16Z")

</div>

Hi there, is there any way to apply a page style using uno commands?

I am doing:

```auto
function post(msg) {
  window.frames[0].postMessage(JSON.stringify(msg), '*');
}

function changePageStyle(pageStyle) {
  post({'MessageId': 'Send_UNO_Command',
        'Values': {
          'Command': '.uno:StyleApply',
          'Args': {
            Arg0Name: {
              type: 'string',
              value: 'Template'
            },
            Arg0Value: {
              type: 'string',
              value: pageStyle
            },
            Arg1Name: {
              type: 'string',
              value: 'Family'
            },
            Arg1Value: {
              type: 'int', // also tried string, integer
              value: 8
            }
          }
        }
      });
}

function receiveMessage(event) {
	// Receive message from Iframe
	console.log('ReceiveMessage: ' + event.data);
	var msg = JSON.parse(event.data);
	if (!msg) {
    console.log('NO ReceiveMessage ');
	}
}

window.addEventListener("message", receiveMessage, false);

changePageStyle("TemplateLandscape")

```

… and nothing is happening - the event listener is not fired, no console error. This shows in the log:

`kit-00254-00022 2023-10-31 23:21:50.483970 +0000 [kitbroker_00e] DBG #18: child_ws: recv [child-0b2 uno .uno:StyleApply {"Arg0Name":{"type":"string","value":"Template"},"Arg0Value":{"type":"string","value":"TemplateLandscape"},"Arg1Name":{"type":"string","value":"Family"},"Arg1Value":{"type":"int","value":8}} | kit/Kit.cpp:2527`

I am making assumptions regarding what the uno command arguments should be based on the following working BASIC snippet:

```auto
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Template"
args1(0).Value = "Landscape"
args1(1).Name = "Family"
args1(1).Value = 8

dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args1())

```

Thanks
