PDA

Click to See Complete Forum and Search --> : Solved, OP can delete it. Export part of excelsheet automatically


hufada
Jun 19th, 2006, 10:10 AM
HI, all, I tried to export part of the excel sheet to a text file. I used the folowing code, With Application.GetSaveAsFilename(), someone has to click on the "SAVE" button in the pop-up window. Is there a way I can save the text file without the click?

Thank you very much.

Public Sub Dotheexport()
Dim FName As Variant
Dim Sep As String

FName = Application.GetSaveAsFilename("C:\Documents and Settings\xyz\Desktop\Data.txt")


If FName = False Then
MsgBox "You didn't select a file"
Exit Sub
End If

Sep = " "
'Sep = InputBox("Enter a single delimiter character (e.g., comma or semi-colon)", _
"Export To Text File")

ExportToTextFile CStr(FName), Sep, _
False
End Sub

Static
Jun 19th, 2006, 12:08 PM
what do u want to trigger the event?

in "ThisWorkbook" drop this code in.. u can hit some other events to trigger it

Dim WithEvents SHT As Worksheet


Private Sub SHT_Activate()

End Sub

Private Sub SHT_Calculate()

End Sub

Private Sub SHT_Change(ByVal Target As Range)

End Sub

Private Sub SHT_SelectionChange(ByVal Target As Range)

End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Set SHT = Sh
End Sub