Try adding a Store request: > Call UnoObj.executeDispatch(document, ".uno:BackgroundColor", "", 0, > propertyset) oSpreadsheet.Store() > oSpreadsheet.Close(True) Close won't do that for you. /tj/
On 3/5/2012 05:10, Subodh Asthana wrote:
Executing UNO Dispatcher in VBScript doesn't reflect any changes in ODS file http://stackoverflow.com/q/9562093/264668?sem=2 Following is the code that I wrote to try formatting ODS using VBSript. It runs without any error but it *does not reflect any change* in the ODS file. Dim propertyset(0) Dim arg() Set oServiceManager = CreateObject("com.sun.star.ServiceManager") Set oDesktop = oServiceManager.createInstance("com.sun.star.frame.Desktop") Set UnoObj = oServiceManager.createInstance("com.sun.star.frame.DispatchHelper") sFileName = "D:\Untitled 1.ods" sFileName = Replace (sFileName, "\", "/") sURL = "file:///"& sFileName Set oSpreadsheet = oDesktop.loadComponentFromURL(sURL, "_blank", 0, arg) 'load existing spreadsheet set oSheet1 = oSpreadsheet.getSheets.getByName( "Sheet1" ) set document = oSpreadsheet.CurrentController.Frame Set propertyset(0) = MakePropertyValue(oServiceManager, "ToPoint", "$A$1") Call UnoObj.executeDispatch(document, ".uno:GoToCell", "", 0, propertyset) Set propertyset(0) = MakePropertyValue(oServiceManager, "BackgroundColor", 16711680) Call UnoObj.executeDispatch(document, ".uno:BackgroundColor", "", 0, propertyset) oSpreadsheet.Close(True) set UnoObj = Nothing set oSpreadsheet = Nothing set oDesktop = Nothing set oServiceManager = Nothing Function MakePropertyValue(oServiceManager, cName, uValue) Dim oStruct Set oStruct = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") Set MakePropertyValue = oStruct End Function
