LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Saving Text File

Hi all,
I need some help with a macro that saves a worksheet as a text file when
called. My issue that I am currently having is getting the text file to save
in the same directory that the original excel spreadsheet was located instead
of the default location. I am admittedly a novice when it comes to VB so
please forgive me if I've made any glaring mistakes.

I've tried to use the curdir function, but without any real results. Again,
I want the "Export Sheet" to save as a text file in the same directory as the
original excel file. I'd like this to be a transparent operation for the
user so they don't "see" any of it happening...

Here is what my code looks like currently:

Sub save_as()


Application.ScreenUpdating = False
Application.DisplayAlerts = False

Sheets("ExportSheet").Select

Dim myPath As String
Dim myFile As String

myPath = curdir("J")
myFile = "import_file"
myFile = myFile & ".txt"

ActiveWorkbook.SaveAs Filename:=myPath & myFile, FileFormat:=xlText,
CreateBackup:=False

Sheets("Sheet1").Select
Sheets("import_file").Name = "ExportSheet"

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

Thank you ahead of time for any and all suggestions!
--
cmungs
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Text File Olan Gotcher Excel Discussion (Misc queries) 1 July 15th 06 10:20 PM
Text file saving, setting file origin mauddib Excel Discussion (Misc queries) 0 May 25th 06 02:50 PM
Saving multi-tab excel file created from comma delimited text file Marcus Aurelius Excel Programming 2 December 19th 05 05:16 PM
saving an excel file as text without text in quotes John Excel Discussion (Misc queries) 2 December 6th 05 06:20 PM
saving an excel file as an ASCII text file without delimiters Sewellst Excel Programming 4 January 7th 05 01:41 PM


All times are GMT +1. The time now is 06:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"