VBScript: Excel read file, update and save file issue



VBScript: Missing the obvious?
I am trying to read an Excel file, update a column, and save the file
with the changes. My code (see example below) does update the columns
OK but I am having issues with the save and Excel close option. If I
open the file after process the script I get prompted the file is
already open and whether I want to reopen the spreadsheet. My true
needs are to update the Excel file and save to the original file while
closing everything at the conclusion of the operation. What am I
missing?
******** Example Code
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\ActiveDirectoryVBScripts
\test.xls")
intRow = 1
strDN = ""
Do Until objExcel.Cells(intRow,1).Value = ""
objExcel.Cells(intRow,2).Value = intRow
intRow = intRow + 1
Loop
objExcel.Save "C:\ActiveDirectoryVBScripts\test.xls"
objExcel.Quit
wscript.echo "Excel Update Routine Completed Normally"

.



Relevant Pages

  • Re: VBScript: Excel read file, update and save file issue
    ... I am trying to read an Excel file, update a column, and save the file ... Set objExcel = CreateObject ... objExcel.Cells(intRow,2).Value = intRow ... Microsoft MVP Scripting and ADSI ...
    (microsoft.public.scripting.vbscript)
  • Re: VBScript: Excel read file, update and save file issue
    ... I am trying to read an Excel file, update a column, and save the file ... Set objExcel = CreateObject ... objExcel.Cells(intRow,2).Value = intRow ... Microsoft MVP Scripting and ADSI ...
    (microsoft.public.scripting.vbscript)
  • Re: Regular Expression Help Required
    ... excel file as input instead of text file, but i am not able to do so. ... Set colMatches = objRegEx.Execute ... forgot to increment your 'intRow' variable. ... Even if you increment your variable, your code will stop at the first ...
    (microsoft.public.scripting.vbscript)
  • Re: VBScript: Excel read file, update and save file issue
    ... I am trying to read an Excel file, update a column, and save the file ... Set objExcel = CreateObject ... objExcel.Cells(intRow,2).Value = intRow ... Microsoft MVP Scripting and ADSI ...
    (microsoft.public.scripting.vbscript)
  • Re: Dynamic Array & ReDim not working too well...
    ... > My problem is not knowing how many entries there will be in this Excel file ... > every day, so I though of using a Dynamic Array, along with the ReDmi ... For intRow = 1 To UBound ...
    (microsoft.public.scripting.vbscript)