Good Day! I would like to seek assistance regarding the macro that I created using OpenOffice Basic and now, I don't know what to do
I'm new to programming, I was reading the guide using this link https://wiki.openoffice.org/w/images/c/ ... o3.2.0.pdf but I'm really having a hard time understanding all the logic there, sometimes I feel I'm crazy lol
What I want to do now is to include a script after For Next Loop and focus the selection from A2 until end of rows in A column.
For example(A2:A15000) and apply search and replace to that specific Column A.
column A starting A2 below has SKU 8-digit number but my problem is there is apostrophe ' at the beginning of each cell.
Code: Select all
REM ***** BASIC *****
Const SColumns = "D,E,F,G,H,I,J,K,M,N,O,P,Q,R,S,T,U,V,W" 'ascending
Sub clearBiArc
Dim Doc As Object
Dim MultiSheets As Object
Dim SingleSheet As Object
Dim oRows As Object
Dim aColumns As Object
Dim oColumn As Object
Doc = ThisComponent
MultiSheets = Doc.getSheets()
SingleSheet = MultiSheets.getByName("BIArcRawData")
oRows = SingleSheet.getRows()
oRows.removeByIndex(0, 17)
oRows.removeByIndex(1, 1)
aColumns = Split(SColumns,",")
'oSheet = ThisComponent.CurrentController.ActiveSheet
For i = uBound(aColumns) to 0 step -1
oColumn = SingleSheet.Columns.getbyname(aColumns(i))
oColumn.Columns().removebyindex(0,1)
Next i
Msgbox "Done"
End Sub
But the problem is it only works if I select the column A, if I don't it will say search key not found, is there a way to integrate below code after my for next loop above or can you suggest a better way to do it.
I have a button in first sheet that once I click it will run the Sub clearBiArc which is located in another spreadsheet on same document. I want to run this code from macro recorder also without having to select manually the column A in the sheet.
Code: Select all
sub removeapos
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 args1(17) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.StyleFamily"
args1(0).Value = 2
args1(1).Name = "SearchItem.CellType"
args1(1).Value = 0
args1(2).Name = "SearchItem.RowDirection"
args1(2).Value = true
args1(3).Name = "SearchItem.AllTables"
args1(3).Value = false
args1(4).Name = "SearchItem.Backward"
args1(4).Value = false
args1(5).Name = "SearchItem.Pattern"
args1(5).Value = false
args1(6).Name = "SearchItem.Content"
args1(6).Value = false
args1(7).Name = "SearchItem.AsianOptions"
args1(7).Value = false
args1(8).Name = "SearchItem.AlgorithmType"
args1(8).Value = 1
args1(9).Name = "SearchItem.SearchFlags"
args1(9).Value = 71680
args1(10).Name = "SearchItem.SearchString"
args1(10).Value = "^[0-9]"
args1(11).Name = "SearchItem.ReplaceString"
args1(11).Value = "&"
args1(12).Name = "SearchItem.Locale"
args1(12).Value = 255
args1(13).Name = "SearchItem.ChangedChars"
args1(13).Value = 2
args1(14).Name = "SearchItem.DeletedChars"
args1(14).Value = 2
args1(15).Name = "SearchItem.InsertedChars"
args1(15).Value = 2
args1(16).Name = "SearchItem.TransliterateFlags"
args1(16).Value = 1280
args1(17).Name = "SearchItem.Command"
args1(17).Value = 3
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
end sub
I'm sorry if I typed many words, I'm really sorry, can you also put comments so I can learn how you done it.
Hoping for someone kind response.
Thank you so much