Running A Macro With Arguments From Progressl

John Y

New Member
Hi,

Progress 8.2c
Excel 2000

I am trying to run a Macro with arguments from progress. The purpose of the Macro is to load a CSV file and format specific columns to Text. I am having difficulty writing the VBA code to accept arguments (New to VBA).

The result I am wanting is to put arguments in the 'array' part of the statement so I can create a generic macro to import any csv file and format any specific columns to text.

Any help on the VBA Code would be appreciated.

The progress code I am using is :-

def var w-excel as com-handle NO-UNDO.

create "excel.application" w-excel.

w-excel:run("importcsv",2,5).


i.e 2 & 5 represent columns 2 and 5 in excel which I want formating as text.
____________________________________

The macro code is :-

Sub Importcsv()


Workbooks.OpenText Filename:="C:\WINDOWS\Desktop\Test2.txt", Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="^", FieldInfo:= _
Array(Array(2, 2), Array(5, 2))
 
Hello,

I haven't fully tested the code, but I think the following should work:

Public Sub Importcsv(ByVal arg1 As Integer, ByVal arg2 As Integer)

Workbooks.OpenText Filename:="C:\WINDOWS\Desktop\Test2.txt", Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="^", FieldInfo:= _
Array(Array(arg1, 2), Array(arg2, 2))

End Sub
 
Back
Top