Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Just a column on a worksheet

I have a routine that searches and replaces text strings throughout a whole workbook.

sub MyFindReplace(strSearch, strReplace)
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args(7) as new com.sun.star.beans.PropertyValue
args(0).Name = "SearchItem.AllTables"
args(0).Value = true
args(1).Name = "SearchItem.SearchFiltered"
args(1).Value = false
args(2).Name = "SearchItem.Pattern"
args(2).Value = false
args(3).Name = "SearchItem.Content"
args(3).Value = false
args(4).Name = "SearchItem.AlgorithmType"
args(4).Value = 0
args(5).Name = "SearchItem.SearchString"
args(5).Value = strSearch
args(6).Name = "SearchItem.ReplaceString"
args(6).Value = strReplace
args(7).Name = "SearchItem.Command"
args(7).Value = 3

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args())

end sub

How do I get it to operate only on a specific column on a specific worksheet? Thanks.

Just a column on a worksheet

I have a routine that searches and replaces text strings throughout a whole workbook.

sub MyFindReplace(strSearch, strReplace)
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args(7) as new com.sun.star.beans.PropertyValue
args(0).Name = "SearchItem.AllTables"
args(0).Value = true
args(1).Name = "SearchItem.SearchFiltered"
args(1).Value = false
args(2).Name = "SearchItem.Pattern"
args(2).Value = false
args(3).Name = "SearchItem.Content"
args(3).Value = false
args(4).Name = "SearchItem.AlgorithmType"
args(4).Value = 0
args(5).Name = "SearchItem.SearchString"
args(5).Value = strSearch
args(6).Name = "SearchItem.ReplaceString"
args(6).Value = strReplace
args(7).Name = "SearchItem.Command"
args(7).Value = 3

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args())

end sub

How do I get it to operate only on a specific column on a specific worksheet? worksheet?

If that's not possible, then searching in a selection would be okay too.

Thanks.