View Single Post
 
Old 03-09-2017, 05:39 AM
Alimou Alimou is offline Windows 8 Office 2013
Novice
 
Join Date: Jan 2016
Posts: 4
Alimou is on a distinguished road
Default Help with my macro - Error message

Hi,
Need help please. Any idea why VBA is returning the error message "invalid use of Null”?

Many thanks




Code:
Sub CreateEviewsPrg()

Dim ItemName, nameoffile As String
Dim stufftocopy As Variant
Dim fso, oFile As Object
Dim crange, c, loc As Range

'Set folder = Sheets("Parameters").Range("C9").Value

With Worksheets("Prg_xSc")

            nameoffile = .Cells(1, 1).Value
            Set crange = Range(.Cells(1, 2).Value) 
            Set stufftocopy = crange
            Set c = stufftocopy
            ItemName = ItemName + c.Text + vbCrLf
                
            Set fso = CreateObject("Scripting.FileSystemObject")
            Set oFile = fso.CreateTextFile("\\xxx\Eviews\" + CStr(nameoffile) + ".prg")

            oFile.WriteLine CStr(ItemName) 'ERROR HERE: "invalid use of Null”

            oFile.Close
            Set fso = Nothing
            Set oFile = Nothing
            

End With




End Sub
Reply With Quote