hey im writing an excel automation file to take vaules from an excel file, store them in a temp file and them place back into the original file once that file is erased. It is for my work, this would same me tons of time, as of now they have me re-entering a lot of numbers that dont need to be. anyways ive got some of the prgm done but im stuck. after i run the script the values are not stored in the temp file. why is this, I cant figure it out. btw im brand new to vbscript this is my first attempt at scripting i just started yesterday, so if you have any tips for my script or things seem backwards, any pointers would be very helpful. anyways heres the code:
THANKS!!
rjr
Code:
Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile, objWorkbook
Dim strDirectory, strFile, strText, strMonth, strDay, strYear, dtmDate
Dim objExcel, excelPath
strDirectory = "E:\temp"
strFile = "\chckouttmp.txt"
excelPath = "E:\temp\xlschckouttemp.xls"
createfile()
callclosingcash()
objExcel.Workbooks(1).Close
objExcel.Quit
Function createfile()
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " & strDirectory
End If
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
Wscript.Echo "Just created " & strDirectory & strFile
End If
If objFSO.FileExists(strDirectory & excelPath) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objExcel = CreateObject("Excel.Application")
objExcel.DisplayAlerts = 0
Set objWorkbook = objExcel.Workbooks.Add()
objWorkbook.SaveAs(excelPath)
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
End If
set objFile = nothing
set objFolder = nothing
end function
Function callclosingcash()
Dim loopCount, directory, objExcel, workbook
Set objExcel = CreateObject("Excel.Application")
'Gets the directory where our script is running from
directory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(Wscript.ScriptFullName)
'Open our XLS file
Set workbook = objExcel.Workbooks.Open(directory & "\checkoutassistant.xls")
Dim i, j 'For looping through the columns on each row
i = 7
j = 4
Dim value 'Value extracted from each cell
objExcel.Workbooks.Open(excelPath)
'Move down Closhing Cash Getting Values
For i = 7 To 17
value = objExcel.Cells(i, 3).Value
'Store in temp check out
objExcel.Cells(j, 1).Value = value
j = j + 1
Next
end Function
THANKS!!
rjr