Tag: fso

  • VBA Code To Create An excel File

    Sub CreateNewFile ()

    Dim wkOut as Workbook
    Dim wbAddr as string 
    Dim fso
     ‘wbAddr holds the path where the file needs to be created
     ‘like wbAddr=”D:\VbaCodes” 
    Set fso = CreateObject(“Scripting.FileSystemObject”)
    Set wkOut = Workbooks.Add
    ‘Output.xls is the file to be created. A file or workbook is same.
    wkOut.SaveAs filename:=wbAddr + “Output.xls”
    Set wkOut = Workbooks.Open(wbAddr + “Output.xls”)
    Set wkOut = Workbooks(“Output.xls”)

    End Sub