How to use Excel workbook.saveas with automatic overwrite

excelObject.DisplayAlerts = False

Set excelObject = CreateObject("Excel.Application")    
excelObject.DisplayAlerts = False
Set wb = excelObject.Workbooks.Add
fullFilePath = importFolderPath & "\" & "A.xlsx"

wb.SaveAs fullFilePath, AccessMode:=xlExclusive,ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges    
wb.Close (True)

 

 

 

https://stackoverflow.com/questions/14634453/how-to-use-workbook-saveas-with-automatic-overwrite

Advertisements

MS Script Debugger missing – solved

When installing QTP/UFT you select to install Microsoft Script Debugger.

Now MS removed it from their site.

see here for solution (download and install it manually)

http://www.learnqtp.com/ms-script-debugger-error-uft/

the file name is scd10en.exe/zip so you can search for it yourself.

 

insert a line into a text file after a specific line

from

https://community.spiceworks.com/scripts/show/1709-add-a-line-of-text-into-a-file

briefly:

set objWS = CreateObject("Wscript.Shell")
Set fsob=CreateObject("Scripting.FileSystemObject")

strNewLine = "INSERT LINE TO ADD"
strFileName = "INSERT THE FILE PATH HERE" ' for example c:\textfile.txt

Const FOR_READING = 1
Const FOR_WRITING = 2
strCheckForString = UCase("NEW LINE WILL BE INSERTED AFTER THIS TEXT")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFileName, FOR_READING)
strContents = objTS.ReadAll
objTS.Close
arrLines = Split(strContents, vbNewLine)
Set objTS = objFS.OpenTextFile(strFileName, FOR_WRITING)
For Each strLine In arrLines
  If (Left(UCase(LTrim(strLine)),Len(strCheckForString)) = strCheckForString) Then
    objTS.WriteLine strLine
    objTS.WriteLine strNewLine
  else
    objTS.WriteLine strLine
  End If
Next