Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When i excute this file. when the cursor reaches the position
" LResult = FileSize(Filename)" It is going to the "ErrorHandler: ActiveSheet.Columns((GetColumnCount + 1)).ClearContents" Please let me know what wrong iam doing in this code. ..Public Sub ExportToFile() On Error GoTo ErrorHandler Dim ts As TextStream Dim Filename As String, fileContent As String, tableName As String, delimiter As String Dim rowCount As Long, columnCount As Long, dataColumn As Long, pageSize As Long Dim pageNumber As Integer Dim tempRange As Range, tempCell As Range Dim ws As Worksheet Dim MyName As String Dim xpathname As String Dim fso As FileSystemObject Dim LResult As Long Dim ConstLen As Long For Each ws In ActiveWorkbook.Worksheets Filename = ws.Name If Filename < "Anvil" Then Worksheets(Filename).Activate 'fileName = GetDefaultFileName(wkSheetName) If Filename = "" Then Exit Sub 'fileName = Application.GetSaveAsFilename(fileName, "Data Files (*.txt),*.txt", _ ' 1, "Save Data File", "Export") xpathname = ThisWorkbook.Path Filename = xpathname & "\" & Filename & ".txt" LResult = FileSize(Filename) ConstLen = 0 If LResult = ConstLen Then ConstLen = 1 ElseIf MsgBox("The file " & fso.GetFileName(Filename) & " already exists. Do " & _ "you want to replace the existing file?", vbYesNo + vbExclamation + _ vbDefaultButton2, PROJECT_NAME) = vbNo Then Exit Sub End If Set fso = New FileSystemObject fso.CreateTextFile Filename, overwrite:=True Exit Sub ErrorHandler: ActiveSheet.Columns((GetColumnCount + 1)).ClearContents MsgBox MSG2002, vbOKOnly + vbCritical, PROJECT_NAME End Sub Public Function FileSize(Filename As String) As Long Dim objX As Object Set objX = CreateObject("Scripting.FileSystemObject") FileSize = objX.GetFile(Filename).Size Set objX = Nothing End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Exception from HRESULT: 0x800A03EC - COM Exception Unhandled | Excel Programming | |||
How do I find invisible objects contributing to excel file size? | Excel Discussion (Misc queries) | |||
EXCEL VBA - Find Method or Range in IE throwing error | Excel Programming | |||
Unable to open excel file and when view the file size show as 1 KB | Excel Discussion (Misc queries) | |||
Unable to change plot area size | Excel Programming |