actually i have a very large code in excel vba. and it is really working very well. but when i m trying to use this code to vb.net then a part of this code is not working. i.e.

Dim fnum As Variant
Dim FileName As Variant
FileName = Application.GetSaveAsFilename(InitialFileName:="Voucher", FileFilter:="Text Files (*.xml),*.xml")
    If FileName = False Then
        ''''''''''''''''''''''''''
        ' user cancelled, get out
        ''''''''''''''''''''''''''
        End
        Exit Sub
    End If
    'Debug.Print "FileName: " & FileName, "Separator: " & Sep
    fname = CStr(FileName)

fnum = FreeFile

    Open fname For Output Access Write As #fnum
    Print #fnum, st

'EndMacro:
On Error GoTo 0
Close #fnum

Can any expert help me on this issue.........
Thanks in advance..

Regards
CA Mahaveer Somani

In the above code line no. 17 there is one word "st"

it is Dim st As String

and st is not blank it gets some value before above part of the code.

Thanks in advance experts

I would change

Dim fnum As Variant
Dim FileName As Variant

into

Dim fnum As Integer
Dim FileName As String