How to save this file

I am getting errors in thisSub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument



On Error Goto Errorhandle	

Set uidoc=ws.CurrentDocument



Dim x As Variant

’ Open Excel Application

Set z=createobject("Excel.Application")

z.visible=True

z.workbooks.add

z.caption="Exporting From Notes Current Document  to Excel"

z.worksheets(1).Name="Customer Info"

z.worksheets(1).Range("A1").value="Customer Details"

z.worksheets(1).Range("A3").value=" Name"

z.worksheets(1).Range("B3").value="Email"

z.worksheets(1).Range("C3").value="Phone"

z.worksheets(1).Range("D3").value="Address"

’ Export Data from Notes Document

Dim s As String ' taking for range

Dim i As Integer ' taking for column

i=2

Set  x=z.workbooks(1).worksheets(1)

While Not uidoc Is Nothing

	Gosub Export

Wend

If uidoc Is Nothing Then

	Gosub Terminate

End If

’ Export Values from Out Door View

Export :

s="A"+Cstr(3+i)+":C"+Cstr(3+i)

x.cells(i+3,1).value=Cstr(uidoc.FieldGetText("CuName")) ' Item

x.cells(i+3,2).value=Cstr(uidoc.FieldGetText("CuEmail")) ' Item

x.cells(i+3,3).value=Cstr(uidoc.FieldGetText("CuPhone"))' Item

x.cells(i+3,3).value=Cstr(uidoc.FieldGetText("CuCity"))      'item

x.cells(i+3,4).value=Cstr(uidoc.FieldGetText("CuAddress")) ' Item	

x.save  "Desktop\Exporttoexcel.xls"

z.Quit

Terminate :

Exit Sub

Errorhandle:

Messagebox "Error:" &  Error & " at line " & Cstr(Erl)

How to savethis excel file in a filesystem and if it exist I need to overwrite it and quit

with hope

thanks

Subject: how to save this file

Hi,

It would help if you posted what errors you were getting!

Looking at the code i can see a few issues. Why are you using a While loop that is testing on uidoc is nothing? You are never setting it to nothing, so your code will just loop ad infinitum.

Also you not incrementing i, so you will always be exporting the same row of data.

With regards to saving the file, you first need to check if a file exists (see the Dir command) and if so use the Kill command to delete the existing file.