I am not programer but I can copy paste some macro from here and from stackoverflow but little bit not understand programing language.
I have formr calc file where one line is changing once execute macro and I need to add this row with cooma separators to new line in csv file via macro
I already have this macro and I have multiple form files but if users execute this macro in same time one file show error of writing to this csv file. Can you help me to solve it?
Macro:
Sub SaveCSV
Dim oDocA As Object, oDocB As Object, oSheetA As Object, Dummy(), oRangeA as object, targetcell as object
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oDocA = ThisComponent
oFrameA = oDocA.CurrentController.Frame
oSheetA = oDocA.getSheets.getByIndex(7)
oRangeA = oSheetA.getCellRangeByName("C3:P3")
oDocA.CurrentController.Select(oRangeA)
oDispatcher.executeDispatch(oFrameA, ".uno:Copy", "", 0, Dummy())
oDocB = StarDesktop.loadComponentFromURL ("file:///C:/TEMP/Summary.csv", "_blank",0, Dummy() )
oSheetB = oDocB.getSheets.getByIndex(0)
c = oSheetB.createCursor
c.gotoEndOfUsedArea(false)
LastRow = c.RangeAddress.EndRow +1
targetcell= oSheetB.getCellByPosition(0,LastRow)
oDocB.CurrentController.Select(targetcell)
oFrameB = oDocB.CurrentController.Frame
oDispatcher.executeDispatch(oFrameB, ".uno:Paste", "", 0, Dummy())
oDocB.Store
oDocB.close(true)
ASheet.protect(psw)
ASheet = ThisComponent.Sheets.getByName("Formular")
ThisComponent.CurrentController.setActiveSheet(ASheet)
End Sub