Results 1 to 4 of 4
  1. #1
    jrdnoland is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Ohio
    Posts
    41

    How would I save Plain text from a textbox as a File where I could give the file a name and ....


    ..location to save it. Also want to do the same things with a Rich Text text box. and Finally be able to load into the respective text boxes a saved file.

    Here's what I have so far:
    Code:
    Private Sub cmdSavePlain_Click()
    Dim dlgOpen As FileDialog
    Dim myTxt As String
    myTxt = txtSource 'whatever text box your text is in
    Open "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\Temporary Attachments\Plain Text x.txt" For Append As #1 ' change the path to reflect your path
    Print #1, myTxt
    Close #1
    Set dlgOpen = Application.FileDialog(msoFileDialogSaveAs)
        With dlgOpen
        .InitialFileName = "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\Temporary Attachments\Plain Text x.txt"
        .Show
    End With
    End Sub
    
    Private Sub cmdSaveRich_Click()
    Dim dlgOpen As FileDialog
    Dim myTxt As String
    myTxt = txtHTML 'whatever text box your text is in
    Open "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\Temporary Attachments\Rich Text x.txt" For Append As #1 ' change the path to reflect your path
    Print #1, myTxt
    Close #1
    Set dlgOpen = Application.FileDialog(msoFileDialogSaveAs)
        With dlgOpen
        .InitialFileName = "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\Temporary Attachments\Plain Text x.txt"
        .Show
    End With
    End Sub

  2. #2
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Maybe take a look at FileSystemObject textstream object

    https://docs.microsoft.com/en-us/off...tstream-object
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    jrdnoland is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Ohio
    Posts
    41
    Quote Originally Posted by moke123 View Post
    Maybe take a look at FileSystemObject textstream object

    https://docs.microsoft.com/en-us/off...tstream-object
    I was actually hoping for some code to get me started. I'll look over this info and see what I can do with it.

  4. #4
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Quote Originally Posted by jrdnoland View Post
    I was actually hoping for some code to get me started. I'll look over this info and see what I can do with it.
    Here's a quick example

    fyi - only really works for plain text but will save the markup in a txt file. If you comment out the afterupdate code in the filename textbox, you can save it as html which will format the rich text.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Writing to a text file and linking table to text file
    By NightWalker in forum Programming
    Replies: 17
    Last Post: 07-21-2020, 04:35 PM
  2. Browse to a File and Save Path in a Text Field
    By PSSMargaret in forum Access
    Replies: 2
    Last Post: 03-27-2017, 08:05 AM
  3. Replies: 4
    Last Post: 04-26-2016, 08:41 AM
  4. Replies: 2
    Last Post: 12-27-2012, 09:37 AM
  5. Replies: 1
    Last Post: 06-09-2011, 11:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums