TheBugSlayer
Programmer
Hi.
Can anyone give me a walktrough or some samples on how to use VBA or to manipulate a spreadsheet in Delphi 6?
Here is a little procedure I would like to convert to Delphi.
Can anyone give me a walktrough or some samples on how to use VBA or to manipulate a spreadsheet in Delphi 6?
Here is a little procedure I would like to convert to Delphi.
Code:
[COLOR=red]
Sub DCCenter()
Application.DisplayAlerts = False
ChDir "C:\My Projects\DupPay2\CurrentSys"
Workbooks.OpenText Filename:="C:\My Projects\DupPay2\CurrentSys\duhdc", _
Origin:=xlWindows, StartRow:=6, DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 1), Array(1, 2), Array(10, 3), Array(18, 2), Array(74, 2), Array(90, 2), _
Array(106, 9), Array(130, 2))
Range("B1").Select
Selection.Cut
Range("C1").Select
ActiveSheet.Paste
Dim y As Integer
y = 1
Dim Current As Range
While Cells.Item(y, 1) <> ""
Set Current = Cells.Item(y, 1)
If IsDate(Cells.Item(y, 3)) Then
Cells.Item(y, 11).Value = "DC"
Cells.Item(y, 12).Value = Cells.Item(1, 3).Value
Else
Cells.Item(y, 3).EntireRow.Delete
y = y - 1
End If
y = y + 1
Wend
Rows("1:1").Select
Selection.Delete Shift:=xlUp
y = 2
While Cells.Item(y, 1) <> ""
Range(Cells(y, 3), Cells(y, 4)).Select
Selection.Copy
ActiveSheet.Paste Destination:=Cells(y - 1, 8)
Cells(y, 3).EntireRow.Delete
y = y + 1
Wend
Columns("I:I").Select
Selection.TextToColumns Destination:=Range("I1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(33, 2))
Columns("E:H").Select
Selection.Insert Shift:=xlToRight
Columns("D:D").Select
Selection.TextToColumns Destination:=Range("D1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(17, 2), Array(20, 2), Array(23, 2), Array(41, 2))
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("L:L").Select
Selection.Replace What:="EFT", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1:O1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Application.DisplayAlerts = True
AppActivate "Duplicate Payment DB"
'SendKeys "{Enter}"
'SendKeys "%EA"
'SendKeys "%EN"
'SendKeys "{Enter}"
'SendKeys "%FC"
End Sub
[/color]
Thank you.