+ Reply to Thread
Results 1 to 5 of 5

Call CommandButton

  1. #1
    Registered User
    Join Date
    09-27-2010
    Location
    halifax
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Call CommandButton

    Hello, This is my first post, Im not very good at writing macros but pretty good at following and copying other peoples hard work.

    My aim is to either use some kind of macro express software or ideally perform this as an excel VBA macro.

    I currently have a xls worksheet which has 55 commandbuttons on it. Each button simply opens a database.xls (worksheet) and date/time stamps a cell so we know this particular file has been processed.

    After clicking commandbutton1 which opens my file i need to click another commandbutton1 within that file which will run some code and call a macro. The macro will close and save that file which will take me back to my switch board, ready to click commandbutton2...... etc etc 50 times this takes approximately 2 hours per day.

    Any software, code, advice or recommendations will be gratefully received.

    Thanks MarkO

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,202

    Re: Call CommandButton

    You could have a loop to automate the task, post what you currently have
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,646

    Re: Call CommandButton

    If cell A1 to A50 contain the fullnames of the files that have to be processed

    Please Login or Register  to view this content.



  4. #4
    Registered User
    Join Date
    09-27-2010
    Location
    halifax
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Call CommandButton

    SNB
    (Thanks i'll have a look into that)

    ROY
    I dont currently have any code what so ever. I simply use the commandbuttons like a zombie, My main objective is to try and "call commandbutton1" i have read many articles none of which i can get to work.

    My Current code is irrelevant really but here's a bit.

    My Switch board code:-

    Private Sub CommandButton1_Click()
    Range("d6").Value = Now()
    Workbooks.Open Filename:="C:\x\Database_MAT.xls"
    End Sub

    Private Sub CommandButton10_Click()
    Range("d3").Value = Now()
    Workbooks.Open Filename:="C:\x\Database_RGN.xls"
    End Sub

    Private Sub CommandButton11_Click()
    Range("b7").Value = Now()
    Workbooks.Open Filename:="C:\x\Database_DAN.xls"
    End Sub

    My Database code:-

    Private Sub UPDATE_Click()

    code = InputBox("CODE ?")

    If code <> "x" Then End

    Application.ScreenUpdating = False

    Call UPDATE_DATABASE
    Call NEWSTATUS
    Call MYDOT

    ActiveCell.Select
    ActiveCell.Select

    Application.ScreenUpdating = True

    Application.DisplayAlerts = False

    ActiveWorkbook.Save
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

    MsgBox (" UPDATE COMPLETE")

    ActiveWorkbook.SendMail Recipients:="laptop@x.co.uk", Subject:="x"

    Application.ScreenUpdating = False

    Range("A6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.ScreenUpdating = True

    Selection.End(xlDown).Select

    ActiveWorkbook.Close

    End Sub


    The code im looking for but translated into english rather than vba/sql etc is

    RUN excel.exe
    Open Father_v4.xls
    active window ("father_v4")
    call commandbutton1
    active window ("database_mat")
    call commbandbutton1
    active window ("father_v4")
    call commandbutton2
    active window ("database_rgn")
    etc etc

    Feel free to call me a pest

    Thanks Mark

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,202

    Re: Call CommandButton

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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