+ Reply to Thread
Results 1 to 6 of 6

Power of Macros

Hybrid View

  1. #1
    Registered User
    Join Date
    12-18-2005
    Posts
    4

    Power of Macros

    hi all .. i am new to this forum.. i dont know whether i am postiing this in the right place or wrong.. however i am sorry if it in a wrong category..

    my Question is
    can we using the macros access the menus of excel? ,,, today i got this job to solve and was completely out of idea how to solve it.. they company which asked me for this task are using a sort of cotomized interface of excel.. i am trying to say they added some new menus to excel.. and these new menus can ineract with another external program which takes some data from the excel sheet and does some calculation and print them back in excel

    what i am trying to ask is can a macro do that ?!?

    and if the answer is yes
    how can i access the menues like file and edite through macros..
    and if no
    well what is the alternative way to do it?

    thank you very much in advance

  2. #2
    Dave Peterson
    Guest

    Re: Power of Macros

    Maybe...

    Option Explicit
    Sub testme()

    Dim myCtrl As CommandBarControl

    Set myCtrl = Nothing
    On Error Resume Next
    Set myCtrl = Application.CommandBars("edit").Controls("cut")
    On Error GoTo 0

    If myCtrl Is Nothing Then
    'not found
    Else
    myCtrl.Execute
    End If
    End Sub


    But if these are actually built into excel (like my sample), then there are
    better ways.

    =====
    And if they are customized controls, maybe you can find the name of the macro
    that's being called and just call that directly:

    application.run "'myaddinnamehere.xla'!nameofmacrohere"

    Lots of times, the developer of the addin gives that information out in the
    instructions--just so that other developers can call it directly.

    If you don't get that info, maybe you can snoop to find it.
    Load the addin
    tools|Customize (just to have that dialog visible)
    expand any menu you need to see the new option.
    right click on that new option and choose assign macro.

    You may get lucky.

    (And cancel your way out--don't do any damage.)



    Mr_Flamenco wrote:
    >
    > hi all .. i am new to this forum.. i dont know whether i am postiing
    > this in the right place or wrong.. however i am sorry if it in a wrong
    > category..
    >
    > my Question is
    > can we using the macros access the menus of excel? ,,, today i got this
    > job to solve and was completely out of idea how to solve it.. they
    > company which asked me for this task are using a sort of cotomized
    > interface of excel.. i am trying to say they added some new menus to
    > excel.. and these new menus can ineract with another external program
    > which takes some data from the excel sheet and does some calculation
    > and print them back in excel
    >
    > what i am trying to ask is can a macro do that ?!?
    >
    > and if the answer is yes
    > how can i access the menues like file and edite through macros..
    > and if no
    > well what is the alternative way to do it?
    >
    > thank you very much in advance
    >
    > --
    > Mr_Flamenco
    > ------------------------------------------------------------------------
    > Mr_Flamenco's Profile: http://www.excelforum.com/member.php...o&userid=29733
    > View this thread: http://www.excelforum.com/showthread...hreadid=494435


    --

    Dave Peterson

  3. #3
    Registered User
    Join Date
    12-18-2005
    Posts
    4

    Another Problem

    Thanx bro.. that was really helpful and cooool thing


    i have another problem

    i have two difference sheets in excel.. and i need to copy some data from the 2nd sheet to the 1st sheet.. the problem is.. the data i want to copy are Row wise and i want to paste them Column.. and there are not in one range.. i mean for example : A1 B1 D1 H1 K1 and i want to paste them in A1 A4 A5 A8 A10

    and each time i want to copy it should copy from the next row i.e A2 B2 D2 H2 K2 and paste them to the same column i.e A1 A4 A5 A8 A10

    and all this is done thought a botton... i am not an excel or VB programmer so i am facing some difficulties with it..

    thank you in Advance

  4. #4
    Dave Peterson
    Guest

    Re: Power of Macros

    You're gonna be pasting over the same cells each time--always a1, a4, a5, a8,
    a10??

    And how do you know when to advance to the next row???

    Option Explicit
    Sub testme()

    Dim fWks As Worksheet
    Dim tWks As Worksheet
    Dim iRow As Long
    Dim iCtr As Long
    Dim fCols As Variant
    Dim tAddr As Variant

    Set fWks = Worksheets("Sheet1")
    Set tWks = Worksheets("sheet2")

    fCols = Array("a", "B", "d", "H", "k")
    tAddr = Array("a1", "a4", "a5", "a8", "a10")

    If UBound(fCols) <> UBound(tAddr) Then
    MsgBox "Design error!"
    Exit Sub
    End If

    With fWks
    .Activate
    iRow = ActiveCell.Row 'how do you know which one to use?
    For iCtr = LBound(fCols) To UBound(fCols)
    fWks.Cells(iRow, fCols(iCtr)).Copy _
    Destination:=tWks.Range(tAddr(iCtr))
    Next iCtr
    End With
    End Sub





    Mr_Flamenco wrote:
    >
    > Thanx bro.. that was really helpful and cooool thing
    >
    > i have another problem
    >
    > i have two difference sheets in excel.. and i need to copy some data
    > from the 2nd sheet to the 1st sheet.. the problem is.. the data i want
    > to copy are Row wise and i want to paste them Column.. and there are
    > not in one range.. i mean for example : A1 B1 D1 H1 K1 and i want to
    > paste them in A1 A4 A5 A8 A10
    >
    > and each time i want to copy it should copy from the next row i.e A2 B2
    > D2 H2 K2 and paste them to the same column i.e A1 A4 A5 A8 A10
    >
    > and all this is done thought a botton... i am not an excel or VB
    > programmer so i am facing some difficulties with it..
    >
    > thank you in Advance
    >
    > --
    > Mr_Flamenco
    > ------------------------------------------------------------------------
    > Mr_Flamenco's Profile: http://www.excelforum.com/member.php...o&userid=29733
    > View this thread: http://www.excelforum.com/showthread...hreadid=494435


    --

    Dave Peterson

  5. #5
    Registered User
    Join Date
    12-18-2005
    Posts
    4

    Another Problem

    Thanx bro.. that was really helpful and cooool thing


    i have another problem

    i have two difference sheets in excel.. and i need to copy some data from the 2nd sheet to the 1st sheet.. the problem is.. the data i want to copy are Row wise and i want to paste them Column.. and there are not in one range.. i mean for example : A1 B1 D1 H1 K1 and i want to paste them in A1 A4 A5 A8 A10

    and each time i want to copy it should copy from the next row i.e A2 B2 D2 H2 K2 and paste them to the same column i.e A1 A4 A5 A8 A10

    and all this is done thought a botton... i am not an excel or VB programmer so i am facing some difficulties with it..

    thank you in Advance

  6. #6
    Registered User
    Join Date
    12-18-2005
    Posts
    4

    Another Problem

    Thanx bro.. that was really helpful and cooool thing


    i have another problem

    i have two difference sheets in excel.. and i need to copy some data from the 2nd sheet to the 1st sheet.. the problem is.. the data i want to copy are Row wise and i want to paste them Column.. and there are not in one range.. i mean for example : A1 B1 D1 H1 K1 and i want to paste them in A1 A4 A5 A8 A10

    and each time i want to copy it should copy from the next row i.e A2 B2 D2 H2 K2 and paste them to the same column i.e A1 A4 A5 A8 A10

    and all this is done thought a botton... i am not an excel or VB programmer so i am facing some difficulties with it..

    thank you in Advance

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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