Results 1 to 4 of 4

Button functionality separation

Threaded View

  1. #1
    Registered User
    Join Date
    08-05-2015
    Location
    Stockholm, Sweden
    MS-Off Ver
    2013
    Posts
    7

    Button functionality separation

    I'm new to Excel macros & VBA and I'm trying to invoke Shell commands from 2 buttons. They have similar functionality except for one line in them. I simply copy/pasted Button1 into another cell and modified it. The problem I'm having is that Button1 works perfectly but Button2 does nothing. When I try to modify the script for one button, the other stops working (and vice versa) and afterwards it looks like the same code is somehow copied to both buttons (not wanted). My underlying script for both buttons:

    Button1 (works):

    Option Explicit

    Private Sub CommandButton1_Click()



    Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
    myFile = "C:\test\source-destination.txt"
    'myFile = Application.GetOpenFilename()

    Dim RetVal

    RetVal = Shell("C:\test\launch-this.bat", 1)

    RetVal = Shell("C:\Program Files\Wireshark\tshark.exe -i ""Local Area Connection"" -a duration:10 -w c:\test\streamcapture.cap", 1)

    RetVal = Shell("C:\Program Files\Wireshark\tshark.exe -r c:\test\streamcapture.cap -R ""rtmpt.handshake.c0 == 03"" -w c:\test\handshake.cap -2", 1)

    RetVal = Shell("C:\Program Files\Wireshark\tshark.exe -r c:\test\handshake.cap -E separator=, -t ad > c:\test\source-destination.txt", 1)



    Open myFile For Input As #1
    Do Until EOF(1)
    Line Input #1, textline
    text = text & textline
    Loop
    Close #1

    posLat = InStr(text, "latitude")
    posLong = InStr(text, "longitude")

    Range("D5").Value = Mid(text, posLat + 47, 13)
    Range("E5").Value = Mid(text, posLat + 60, 14)

    Range("D6").Value = Mid(text, posLat + 196, 13)
    Range("E6").Value = Mid(text, posLat + 210, 14)



    End Sub


    /////////////////////////////////////////////////////////////////////////////

    Button2 (does not react. yes I did try changing the button name in properties)

    Option Explicit

    Private Sub CommandButton1_Click()



    Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
    myFile = "C:\test\source-destination.txt"
    'myFile = Application.GetOpenFilename()

    Dim RetVal

    RetVal = Shell("C:\test\launch-this.bat", 1)

    RetVal = Shell("C:\Program Files\Wireshark\tshark.exe -i ""Local Area Connection"" -a duration:10 -w c:\test\streamcapture.cap", 1)

    RetVal = Shell("C:\Program Files\Wireshark\tshark.exe -r c:\test\streamcapture.cap -R ""rtmpt.handshake.c0 == 03"" -w c:\test\handshake.cap -2", 1)

    RetVal = Shell("C:\Program Files\Wireshark\tshark.exe -r c:\test\handshake.cap -E separator=, -t ad > c:\test\source-destination.txt", 1)



    Open myFile For Input As #1
    Do Until EOF(1)
    Line Input #1, textline
    text = text & textline
    Loop
    Close #1

    posLat = InStr(text, "latitude")
    posLong = InStr(text, "longitude")

    Range("D5").Value = Mid(text, posLat + 47, 13)
    Range("E5").Value = Mid(text, posLat + 60, 14)

    Range("D6").Value = Mid(text, posLat + 196, 13)
    Range("E6").Value = Mid(text, posLat + 210, 14)



    End Sub

    Private Sub CommandButton2_Click()

    End Sub


    In summary, I would like to the buttons to be independent of each other since they have different functionality.
    Last edited by wifinut; 08-05-2015 at 05:21 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pop up with policy information with a "voting button" functionality
    By Postlki1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 08:28 AM
  2. How to work with button functionality of a workbook in web?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2012, 06:51 AM
  3. Auto send button/functionality!?
    By Wilgoss in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-20-2012, 01:21 PM
  4. Cannot figure out how to create macro to work with button for needed functionality
    By chairokeeman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-11-2011, 11:59 AM
  5. Printing a Workbook with a push Button functionality
    By dreams in forum Excel General
    Replies: 2
    Last Post: 05-12-2009, 05:21 PM
  6. Name Separation
    By zbatchel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-13-2008, 02:10 PM
  7. Tab Separation
    By ProfDavis in forum Excel General
    Replies: 3
    Last Post: 05-02-2007, 11:59 AM
  8. [SOLVED] Cell Separation
    By Freshman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04: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