'excel range export

i found the code written below, but i dont know how change it to make it to create a file in folder, which is written in X2 cell, insteed of openinig the existing file.

    Dim r As Excel.Range, cell As Excel.Range
    On Error Resume Next
    Set r = Application.InputBox("Select Range", "Select Range", Type:=8)
    On Error GoTo 0
    If r Is Nothing Then Exit Sub

    Open "C:\text.txt" For Output As #1
    For Each cell In r
        Print #1, cell.Value
    Next
    Close
End Sub


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source