How to Code LibreOffice Basic (VBA) to Automatically Increase Number

Problem: I am using LibreOffice version 4.4, currently I use “drag down method” to automatically increase the number, e.g. LT1, LT2, LT3, …., LT100

How do I achieve the same result using LirbreOffice Basic (VBA)?

 

Solution:

REM ***** BASIC *****
Sub Main

rem define variables
dim document as object
dim dispatcher as object

rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(0) as new com.sun.star.beans.PropertyValue
dim args2(0) as new com.sun.star.beans.PropertyValue
dim i as integer 
dim iLT as integer
 rem goto cell "A1"
 args1(0).Name = "ToPoint"
 args1(0).Value = "$A$1"
 dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
 
 rem loop and insert suffix for "LT" of the item code
 For iLT = 401 to 500
 
 rem loop and insert suffix from "00" until "99" into the item code
 For i = 0 to 99
 
 
 args2(0).Name = "StringName"
 if len(i) = 1 then
 args2(0).Value = "06-st-0888-LT" & iLT & "-0" & i
 else
 args2(0).Value = "06-st-0888-LT" & iLT & "-" & i
 end if
 
 rem to enter the item code into the cell
 dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args2())
 
 rem move down one cell
 dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args1())
 
 Next i
 
 Next iLT
End Sub

How to Code LibreOffice Basic (VBA) to Automatically Increase Number