Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Force to SaveAS .txt

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LuisE - 01 Dec 2007 20:54 GMT
I have a button that prompts the SaveAs dialog box.
How can I get the user to be forced to save the file only as .txt
David Sisson - 01 Dec 2007 22:51 GMT
You can't use the built-in SaveAs dialog, read here. http://tinyurl.com/ywca5p

Something like this.

Sub Testing()
Dim MyFile$

MyFile$ = InputBox("Enter Filename without extension", "Save File")

If Len(MyFile$) > 1 Then
   ActiveDocument.SaveAs MyFile$ & ".txt", wdFormatDOSText
Else
   MsgBox "Save cancelled"
End If
End Sub

End Sub
LuisE - 02 Dec 2007 00:02 GMT
Thanks David for the prompt answer.

Just a couple of comments.
What if I need to specify a new path?

I's there any way to open the note Pad from an office application?
I'm creating a word file from the content of a textbox in Excel, any chance
of doing it Note pad?

Thanks

> You can't use the built-in SaveAs dialog, read here. http://tinyurl.com/ywca5p
>
[quoted text clipped - 13 lines]
>
> End Sub
Steve Yandl - 02 Dec 2007 01:40 GMT
LuisE,

I think what I've got between the lines below might do what you want.

_____________________________________

Sub MyTextSave()
With Dialogs(wdDialogFileSaveAs)
  .Format = wdFormatDOSText
  .Name = ActiveDocument.Path & "\" & ActiveDocument.Name
  If .Display Then
     myFileName = WordBasic.FileNameInfo(.Name, 1)
  End If
End With
If Len(myFileName) > 1 Then
  If Not Right(myFileName, 4) = ".txt" Then
     myFileName = myFileName & ".txt"
  End If
  ActiveDocument.SaveAs myFileName, wdFormatDOSText
  ActiveDocument.Close wdSaveChanges
End If
If Application.Documents.Count < 1 Then
  Application.Quit
End If
End Sub

________________________________________

You can certainly open Notepad.exe and load a specific text file from an
office application using Shell.  You can also create a text file using the
Scripting.FileSystemObject object without involving Notepad.  I doubt you
really want or need Notepad opened but perhaps you could explain a bit more
about what you want your users to input and what the final outcome should
be.

Steve Yandl

> Thanks David for the prompt answer.
>
[quoted text clipped - 26 lines]
>>
>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.