+ Reply to Thread
Results 1 to 4 of 4

vbscript to copy data from excel to notepad

Hybrid View

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    1

    vbscript to copy data from excel to notepad

    There are 2 objectives.
    1. Creating a Tracker
    2. Documentation

    I have created a userform which enters the data on a excel sheet. This solves my 1st issue.
    Private Sub buttonReset_Click()
    ' Clear the form
    For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
    ctl.Value = ""
    ElseIf TypeName(ctl) = "CheckBox" Then
    ctl.Value = False
    End If
    Next ctl
    End Sub
    
    Private Sub buttonSubmit_Click()
    Dim RowCount As Long
    Dim ctl As Control
    ' Check User Input
    RowCount = Worksheets("Tracker").Range("A1").CurrentRegion.Rows.Count
    With Worksheets("Tracker").Range("A1")
    .Offset(RowCount, 0).Value = Format(Now, "dd/mm/yyyy hh:nn:ss")
    .Offset(RowCount, 1).Value = Me.txtNetID.Value
    .Offset(RowCount, 2).Value = Me.txtPhone.Value
    .Offset(RowCount, 3).Value = Me.txtLocation.Value
    .Offset(RowCount, 4).Value = Me.txtAccount.Value
    .Offset(RowCount, 5).Value = Me.txtApplication.Value
    .Offset(RowCount, 6).Value = Me.txtBriefIssue.Value
    .Offset(RowCount, 7).Value = Me.txtTemplate.Value
    .Offset(RowCount, 8).Value = Me.txtMoreInfo.Value
    
    End With
    For Each ctl In Me.Controls
    Next ctl
    End Sub
    Once I click on submit it should also launch Notepad with the same data copied onto it.

    How can I get this done?
    Last edited by Leith Ross; 07-21-2014 at 02:10 AM. Reason: Added Code Tags

  2. #2
    Forum Contributor
    Join Date
    08-11-2012
    Location
    bengalur
    MS-Off Ver
    Excel 2003, 2007
    Posts
    152

    Re: vbscript to copy data from excel to notepad

    Sub PrintToTextFile()
    
    Dim FileNum As Integer, cl As Range, z As Integer, y As Integer
    
    Dim myStr As String
    
    FileNum = FreeFile ' next free filenumber
    
    'Open "C:\Temp\TEXTFILE.TXT" For Output As #FileNum ' creates the new file
    
    Open "C:\temp\TEXTFILE.TXT" For Append As #FileNum
    
    Print #FileNum, [a1]
    
    z = 10
    
    For Each cl In [b10:f30]
    
        y = cl.Row
    
        If y = z Then
    
            myStr = myStr & "|" & cl
    
            'appends the input to an existing file write to the textfile
    
        Else: Print #FileNum, myStr
    
            z = cl.Row
    
            myStr = "": myStr = myStr & "|" & cl
    
        End If
    
    Next
    
    'appends the input to an existing file write to the textfile
    
    Print #FileNum, myStr
    
    Close #FileNum ' close the file
    
    End Sub
    Last edited by Leith Ross; 07-21-2014 at 02:11 AM. Reason: Added Code Tags

  3. #3
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: vbscript to copy data from excel to notepad

    Hi shyamhappy..

    How can you be a member here for 2 years with 144 posts and still not notice that everyone else uses code tags when posting code..?

  4. #4
    Forum Contributor
    Join Date
    08-11-2012
    Location
    bengalur
    MS-Off Ver
    Excel 2003, 2007
    Posts
    152

    Re: vbscript to copy data from excel to notepad

    Sorry APO. Next time on wards I will be using code tags.

+ 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. Macro to copy data from excel to notepad
    By emmamaki in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-19-2014, 03:42 AM
  2. Macro to copy data from excel to notepad modified
    By Oldfozzy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2013, 07:36 AM
  3. [SOLVED] Copy excel data to notepad.
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2012, 08:56 AM
  4. [SOLVED] RE: How do i copy columns of data in notepad into microsoft excel?
    By Steven in forum Excel General
    Replies: 0
    Last Post: 02-10-2005, 08:06 PM
  5. [SOLVED] How do i copy columns of data in notepad into excel?
    By JJ in forum Excel General
    Replies: 1
    Last Post: 02-10-2005, 06:06 PM

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