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 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
        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

On Error GoTo 0
Close #fnum

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

CA Mahaveer Somani

Recommended Answers

All 2 Replies

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


Dim fnum As Integer
Dim FileName As String
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.