+ Reply to Thread
Results 1 to 5 of 5

Form to Text File

Hybrid View

  1. #1
    Registered User
    Join Date
    08-20-2012
    Location
    Utah
    MS-Off Ver
    Excel 2010
    Posts
    45

    Form to Text File

    I'm going to describe this the best way I can. I have a text file I'm currently using as a template. There are several areas of the text file that I need to change and then I save it and ultimately copy and paste it to a different program. What I'm looking for is having an excel form where there are fields I can type in and when I submit it allows me to download a text file. Most of the text is static and never changes there are maybe 3 or 4 items in the text that changes. I may not be explaining this very well. Thanks in advance.

  2. #2
    Registered User
    Join Date
    08-20-2012
    Location
    Utah
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Form to Text File

    To help illustrate what I'm trying to accomplish a little better. I've attached a text file. The area that says NUMBERSHERE and TEXTHERE would be what I would want to add to the form. Submitting the form would spit out the completed txt file.
    Attached Files Attached Files

  3. #3
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: Form to Text File

    Here is the code:
    Option Explicit
    
    Private Sub CommandButton1_Click()
    Dim fs As Object
    Dim a As Object
    Dim text As String, folderpath As String
    Unload UserForm1
        Set fs = CreateObject("Scripting.FileSystemObject")
        folderpath = "C:\Users\Bogdan\Desktop\excelforum\rp1783\"
        Set a = fs.CreateTextFile(folderpath & "configfile.txt", True)
        text = Me.Label1.Caption & Me.TextBox1.text & vbCrLf & _
        Me.Label2.Caption & Me.TextBox2.text & vbCrLf & _
        Me.Label3.Caption
        a.WriteLine (text)
        a.Close
    
    Call Shell("explorer.exe" & " " & folderpath, vbNormalFocus)
    
    End Sub
    And the attached file
    Attached Files Attached Files
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  4. #4
    Registered User
    Join Date
    08-20-2012
    Location
    Utah
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Form to Text File

    Form looks great. When I submit it opens the folder I specify, but it doesn't create the file.

  5. #5
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: Form to Text File

    I have no clue why this is happening, could it be write rights on the folder? Is it somewhere on the network?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA code for pulling a sequential number from a text file dependent on a form entry.
    By gjwilson1216 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2013, 05:16 AM
  2. Replies: 1
    Last Post: 08-28-2013, 05:04 PM
  3. [SOLVED] Help me streamline my code? Determine form button background from form text box
    By tivofan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2013, 10:09 AM
  4. Export Excel Form Data to Text File
    By The doomed in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-21-2010, 02:29 PM
  5. Open Word file form Excel using VBA and file path
    By psychoPETE in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-05-2010, 07:02 PM
  6. looping, Open text file, copy text, close text file
    By jwilds1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2009, 05:12 PM
  7. Parsing a text file to a excel or word form
    By Johndeerrm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2005, 05:05 PM
  8. [SOLVED] Adding text file to a user form?
    By Chip in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-29-2005, 03:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1