Converting VB Script macro to VBA for IBM Reflection

BuffettPhan

New Member
Joined
Apr 11, 2009
Messages
1
Any help would be greatly appreciated. We have a VB Script macro we use to pull data from Excel (actually a .csv file) into IBM WRQ Reflection. I am looking for a way to convert the VB Script macro to VBA language to perform the same function (pulling data from Excel); we have a different version of Reflection that runs on VBA. I would think that I wouldn't have to convert the data to .csv format since Excel also uses VBA, but I am a VBA novice. Below is macro we have in VB Script:

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=VB Macro to parse a CSV file for populating a Journal Entry
[PCOMM SCRIPT SOURCE]

autECLSession.SetConnectionByName(ThisSessionName)

Dim IE 'Variable for IE
Dim FSO 'Variable for File System
Dim File_Open 'variable used to Browse
Dim intResult 'variable used during Browse
Dim File 'Variable for Text Input File
Dim File_Line 'variable to hold each line of text from File
Dim JE_Data 'variable array to parse the File_Line
Dim X

'Start IE invisible - used to copy to and from clipboard
Set IE = CreateObject("InternetExplorer.Application")

sub Set_Clip(clip)
IE.Navigate("about:blank")
IE.document.parentwindow.clipboardData.setData "text", cStr(clip)
End sub

'Creates the File Open Browse window
Set File_Open = CreateObject("UserAccounts.CommonDialog")
File_Open.Filter = "Comma Delimited Files (*.CSV)|*.csv|Text Files (*.TXT)|*.txt|All Files (*.*)|*.*"
File_Open.FilterIndex = 1
File_Open.InitialDir = "C:\Documents and Settings\%UserName%\Desktop"

intResult = File_Open.ShowOpen

'Start File System - allows the ability to interact with files, folders, and their properties
Set FSO = CreateObject("Scripting.FileSystemObject")

'Open the text file you are using as the source data
' the "1" is used to set read only
Set File = FSO.OpenTextFile(File_Open.FileName, 1)

'Start the loop of actions
Do While NOT File.AtEndOfStream

'Start a Detail Record Entry Add session
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady

'Read the Text file into a variable
File_Line = File.Readline

'Parse the File_Line variable into an array of Variables
If File_Line <> "" And instr(File_Line,",") > 0 Then
JE_Data = Split(File_Line , ",")

'Starts the loop of pasting each portion of the File_Line
for i = 0 To UBound(JE_Data)

If Left(JE_Data(i),1) = "-" Then
JE_Data(i) = Right(JE_Data(i),Len(JE_Data(i))-1) + "-"
End If

Set_Clip(JE_Data(i))

'Data is now on the clipboard.
autECLSession.autECLPS.SendKeys "[eraseeof]"
autECLMacro "[edit-paste]"
autECLSession.autECLPS.SendKeys "[tab]"
next

End If
'The File_Line of data has been processed
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[tab]"

X = X + 1
If X = 8 Then
autECLSession.autECLPS.SendKeys "[roll up]"
X = 0
End If

Loop

IE.Quit
File.Close
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,225,286
Messages
6,184,069
Members
453,208
Latest member
Palo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top