Forum Discussion
googleid_118035
13 years agoContributor
First I have create new unit under Advanced > Script
Rename the unit as "VB_Func"
Now added following two funtion in that sheet.
Function Get_value_from_file(file,sheet,x,y)
Dim b,c
Set b = CreateObject("Excel.Application")
b.DisplayAlerts = False
Set c = b.Workbooks.Open(file)
Get_val_from_File = c.Worksheets(sheet).Cells(y, x).Value
c.Close True
b.Quit
End Function
Function Insert_value_into_file(file, sheet, x, y, texeres)
Set b = CreateObject("Excel.Application")
b.DisplayAlerts = False
Set c = b.Workbooks.Open(file)
c.Worksheets(sheet).Cells(y, (x+18)).Value = texeres
c.Save
c.Close True
b.Quit
End Function
create new unit under Advanced > Script
Rename the unit as "Test"
Now added following line into "Test" sheet.
Sub Test()
'USEUNIT VB_Func
'declare veriables
file,sheet,x,y,my_veriable,my_inserting_value
'setup veriables
file = "C:\Folder_Name\Test_Data.xls"
sheet = "Sheet1"
x = 3 ' column number
y = 2 ' row numer
'assign Excel file value into a veriables
my_veriable = VB_Func.Get_value_from_file(file,sheet,x,y)
'insert veriable value into an Excel file.
Call VB_Func.Insert_value_into_file(file, sheet, x, y, my_inserting_value)
End Sub
Rename the unit as "VB_Func"
Now added following two funtion in that sheet.
Function Get_value_from_file(file,sheet,x,y)
Dim b,c
Set b = CreateObject("Excel.Application")
b.DisplayAlerts = False
Set c = b.Workbooks.Open(file)
Get_val_from_File = c.Worksheets(sheet).Cells(y, x).Value
c.Close True
b.Quit
End Function
Function Insert_value_into_file(file, sheet, x, y, texeres)
Set b = CreateObject("Excel.Application")
b.DisplayAlerts = False
Set c = b.Workbooks.Open(file)
c.Worksheets(sheet).Cells(y, (x+18)).Value = texeres
c.Save
c.Close True
b.Quit
End Function
create new unit under Advanced > Script
Rename the unit as "Test"
Now added following line into "Test" sheet.
Sub Test()
'USEUNIT VB_Func
'declare veriables
file,sheet,x,y,my_veriable,my_inserting_value
'setup veriables
file = "C:\Folder_Name\Test_Data.xls"
sheet = "Sheet1"
x = 3 ' column number
y = 2 ' row numer
'assign Excel file value into a veriables
my_veriable = VB_Func.Get_value_from_file(file,sheet,x,y)
'insert veriable value into an Excel file.
Call VB_Func.Insert_value_into_file(file, sheet, x, y, my_inserting_value)
End Sub