Link to home
Start Free TrialLog in
Avatar of BalaSee
BalaSee

asked on

Converto to Uppercase

I want to convert a text file content (all) into uppercase ...not the file name, but the content inside the text file
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

How about the following
str = "c:\deleteme\somefile.txt"
    Set fso = CreateObject("scripting.filesystemobject")
    If fso.FileExists(str) Then
        Set fil = fso.opentextfile(str, 1, False)
        If fil.atendofstream Then
            fil.Close
            Exit Sub
        End If
        str = UCase(fil.readall)
        fil.Close
        Set fil = fso.opentextfile(str, 2)
        fil.Write str
        fil.Close
    End If

Open in new window

Avatar of BalaSee
BalaSee

ASKER

---------------------------
Windows Script Host
---------------------------
Script:      D:\test\folderaccess.vbs
Line:      7
Char:      18
Error:      Invalid 'exit' statement
Code:      800A040F
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------
Quite so the problem was I tested in VBA for ease!

Chris
str = "c:\deleteme\somefile.txt"
    Set fso = CreateObject("scripting.filesystemobject")
    If fso.FileExists(str) Then
        Set fil = fso.opentextfile(str, 1, False)
        If not fil.atendofstream Then
            str = UCase(fil.readall)
            fil.Close
            Set fil = fso.opentextfile(str, 2)
            fil.Write str
            fil.Close
        End If
    End If

Open in new window

Avatar of BalaSee

ASKER

---------------------------
Windows Script Host
---------------------------
Script:       D:\test\folderaccess.vbs
Line:      8
Char:      13
Error:      Bad file name or number
Code:      800A0034
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial