Click to See Complete Forum and Search --> : Saving an excel file as a txt file using active X


dafabe
May 15th, 2001, 07:13 AM
I am writing a program that must do the following...........

1. Open an excel file (.xls)
2. Amend the file
3. Save the file as a tabbed text file


At present (using activex) steps 1 nd 2 work corectly, and i can save as a .xls document but the problem lies in the file format (it must be a tabbed text file , I have tried difrent ways of specifying this format but with little success could you please have a look at my program and sugest what code to use.

if i can do this without the save as dialogue box apearing then that will perfect.

Can anyone help?



-DAVE

coolbiz
May 15th, 2001, 07:46 AM
Post your code briefly so that we can take a look at what you're doing right now :)

-Cool Bizs

dafabe
May 15th, 2001, 09:13 AM
This is the main module at present................




Option Explicit
Dim obexcel As Object


















Public Sub OpenExcelFile(strpath As String)
Dim strfilename As String
strfilename = (strpath)

Set obexcel = CreateObject("Excel.Application")


obexcel.workbooks.open strfilename
obexcel.Visible = True
MsgBox "Excel Application Open"

End Sub

Public Sub Amend()
Set obworksheet = obexcel.activesheet

obworksheet.cells(1, 1).Value = "sales"
End Sub


Public Sub SaveExcelFile(strpath As String, strformat As String)
Dim strfilename As String
Dim strfileformat As String

strfileformat = (strformat)
strfilename = (strpath)


Dim blnrunning As Boolean

'Set obexcel = GetObject(, "Excel.Application")
'Set obexcelbasic = GetObject(, "Excel")

'If Err.Number <> 0 Then
' Set obexcel = CreateObject("Excel.Application")

' blnrunning = False
'Else
' blnrunning = True
'End If
'Set obopensheet = CreateObject("Excel.Worksheet")
'Set obworksheet = obexcel.activesheet
'Set obexcelbasic = CreateObject("Excel")
'obexcelbasic.worksheet.SaveAs "c:\4.txt", "xltext") = True
'obexcel.activeworkbook.SaveAs strfilename, strfileformat
'obexcel.activeworkbook.Close False

obexcel.Run.macrosa (strfilename)

If Not (blnrunning) Then
obexcel.Quit
End If

End Sub


As you will notice the savexcelfile sub is a bit messed up this is due to experimentaion.

Thanx

-DAVE

coolbiz
May 16th, 2001, 12:44 PM
I think you've the answer for this already on another forum thread:
http://www.codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=51328&page=0&view=collapsed&sb=5

-Cool Bizs