Hello
Below is my macro which is copying the “used range” of data from a sheet in my source file to a similar sheet in my target file. The macro works fine, but after pasting is completed, my data is now shown as “text” while originally it are numbers (shown as “blue” in Calc). As a result my “graphs” does not work anymore…
Can anyone tell me whats wrong with my macro?
Thanks in advance for any assistance
Willy
Function rangecopy (oDocT as Object, myTargetIdx as Integer, mySourceUrl as String)
Dim oDocS As Object, oSheetS As Object, oRangeS as object
Dim oSheetT As Object, oRangeT as object
Dim Dummy()
dim args1(5) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Flags"
args1(0).Value = "SV"
args1(1).Name = "FormulaCommand"
args1(1).Value = 0
args1(2).Name = "SkipEmptyCells"
args1(2).Value = false
args1(3).Name = "Transpose"
args1(3).Value = false
args1(4).Name = "AsLink"
args1(4).Value = false
args1(5).Name = "MoveMode"
args1(5).Value = 4
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oDocS = OpenCsvAsText (mySourceUrl ) 'Open my CSV source file
rem ----------------------------------------------------------------------
oSheetS = oDocS.getSheets.getByIndex(0) 'The CSV source file contains a single sheet
c = oSheetS.createCursor
c.gotoEndOfUsedArea(false)
LastRow = c.RangeAddress.EndRow
LastColumn = c.RangeAddress.EndColumn
oRangeS = oSheetS.getCellRangeByPosition(0,0,LastColumn,LastRow)
oDocS.CurrentController.Select(oRangeS)
oFrameS = oDocS.CurrentController.Frame
rem ----------------------------------------------------------------------
oSheetT = oDocT.getSheets.getByIndex(myTargetIdx) 'The target file contains several sheets identified by myTargetIdx given as argument
c = oSheetT.createCursor
oRangeT = oSheetT.getCellRangeByPosition(0,0,LastColumn,LastRow)
oDocT.CurrentController.Select(oRangeT)
oFrameT = oDocT.CurrentController.Frame
rem ----------------------------------------------------------------------
oDispatcher.executeDispatch(oFrameS, ".uno:Copy", "", 0, Dummy() )
oDispatcher.executeDispatch(oFrameT, ".uno:Paste", "", 0, args1() )
rem ----------------------------------------------------------------------
oDocS.close(true)
End Function