OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

how can I use replace text uno:ExecuteSearch disable alerts

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
masC
Newbie
Newbie


Joined: 27 Jun 2009
Posts: 1

PostPosted: Sat Jun 27, 2009 5:18 pm    Post subject: how can I use replace text uno:ExecuteSearch disable alerts Reply with quote

Hi,

I am new to open office
.. I am writing a VB.net app using Visual Basic 2008Express to open scalc spreadsheet and find and replace some text..
find [name] replace with MYNAME

I have managed to get something to work but the following code
displays an alert window when [name] string is not found..

is there an alternative to the uno:ExecuteSearch?
Is it possible to disable alerts???
I really don’t want the code to stop and wait for user to click OK on this alert each time it fails to find a string..

Sorry for asking such newbie question.. my VB skills as just as limited as Ooo

any ideas?
thanks


My function :
Code:
  Function openSCalcSearchReplace(ByVal oDispatcher As Object, ByVal frame As Object, ByVal srchString As String, ByVal replString As String) As String
        'generic find and replace option for open office calc spreadsheet
        Dim srchArgs(17) As Object

        srchArgs(0) = MakePropertyValue("SearchItem.StyleFamily", 2)
        srchArgs(1) = MakePropertyValue("SearchItem.CellType", 1)
        srchArgs(2) = MakePropertyValue("SearchItem.RowDirection", True)
        srchArgs(3) = MakePropertyValue("SearchItem.AllTables", True)
        srchArgs(4) = MakePropertyValue("SearchItem.Backward", False)
        srchArgs(5) = MakePropertyValue("SearchItem.Pattern", False)
        srchArgs(6) = MakePropertyValue("SearchItem.Content", False)
        srchArgs(7) = MakePropertyValue("SearchItem.AsianOptions", False)
        srchArgs(8) = MakePropertyValue("SearchItem.AlgorithmType", 0)
        srchArgs(9) = MakePropertyValue("SearchItem.SearchFlags", 65536)
        srchArgs(10) = MakePropertyValue("SearchItem.SearchString", srchString)
        srchArgs(11) = MakePropertyValue("SearchItem.ReplaceString", replString)
        srchArgs(12) = MakePropertyValue("SearchItem.Locale", 255)
        srchArgs(13) = MakePropertyValue("SearchItem.ChangedChars", 2)
        srchArgs(14) = MakePropertyValue("SearchItem.DeletedChars", 2)
        srchArgs(15) = MakePropertyValue("SearchItem.InsertedChars", 2)
        srchArgs(16) = MakePropertyValue("SearchItem.TransliterateFlags", 1280)
        srchArgs(17) = MakePropertyValue("SearchItem.Command", 3)
 

        Call oDispatcher.executeDispatch(frame, ".uno:ExecuteSearch", "", 0, srchArgs)

        srchArgs = Nothing
        openSCalcSearchReplace = True

    End Function





This is how I use it:
Code:
     oServiceManager = CreateObject("com.sun.star.ServiceManager")
        oDispatcher = oServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
        ' Get the Desktop object.
        oDesktop = oServiceManager.createInstance("com.sun.star.frame.Desktop")

Dim aNoArgs(0) As Object
        aNoArgs(0) = MakePropertyValue("Hidden", True)
        Dim authorsName = "MYNAME"

        'make the file path URL type
        Dim htmlFilePath As String
        htmlFilePath = ConvertToUrl(tmplPathFileName)

        ' Create a spreadsheet based on template.
        oCalcDoc = oDesktop.loadComponentFromURL(htmlFilePath, "_blank", 0, aNoArgs)
         
        Dim ctl = oCalcDoc.CurrentController() 
        Dim frame = ctl.Frame() 




openSCalcSearchReplace(oDispatcher, frame, "[name]", authorsName)
openSCalcSearchReplace(oDispatcher, frame, "[street]", "mySTREET")

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group