Results 1 to 13 of 13

Thread: Using Macros

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Using Macros

    how can i put some visible thing of a macro? i mean..like a form, inputbox..whenever i try to put a inputbox it just wont open..if i try to load a form the form freezes i dunno why..anyone has any idea? anyone has worked with macros?
    \m/\m/

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    I just wrote this macro. It works fine for me. Is this something like what you are having trouble with?

    VB Code:
    1. Public Sub macTRIS001()
    2.  
    3.         Dim i As Integer = InputBox("How many times?", "Write the letter 'A'", 0)
    4.  
    5.         Dim x As Integer
    6.         For x = 1 To i
    7.             DTE.ActiveDocument.Selection.Text = "A"
    8.         Next
    9.     End Sub
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yep, that worked, but what about forms? i mean..i want the user to have some options on what to do..how can i accomplish this?
    \m/\m/

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    the way seems to be vs.net addins..anyone had worked in anything of this? any one has any experience/thoughs about this?
    \m/\m/

  5. #5
    Member
    Join Date
    Sep 2002
    Posts
    37
    Hi

    I usually design a standalone Form first and then copy the form class into the macro module. You can then instantiate the form, show it (ShowDialog method) and respond to the user selections on that form.

    Hope this helps

    Harold Hoffman

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    as ive said above everytime i try to instantiate a class it just freezes up.......that doesnt happen to u?
    \m/\m/

  7. #7
    Member
    Join Date
    Sep 2002
    Posts
    37
    Hi

    My Forms work fine in a macro. If you post your macro I'll try it out.

    Harold Hoffman

  8. #8

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    sub Test()
    dim f as new Form()
    f.ShowDialog()
    end sub

    this aint working..

    btw are utalking about MACROS or VS.NET ADDINS? they're different things!
    \m/\m/

  9. #9
    Member
    Join Date
    Sep 2002
    Posts
    37
    Hi

    Yes. I am talking about macros not addins. Where is your Form class defined?

    Harold Hoffman

  10. #10

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    for testing purposes i didnt create a form for myself, i just instanciated as in the above code a "regular" form but is keeps freezing :S
    \m/\m/

  11. #11
    Member
    Join Date
    Sep 2002
    Posts
    37
    Hi

    I tested your code and it works fine. I also added a button and it also appeared on the form.

    Sub Macro1
    Dim f As New Form()
    Dim btnSave As New Button()
    btnSave.Visible = True
    btnSave.Text = "Save"
    f.Controls.Add(btnSave)
    f.ShowDialog()
    End Sub

    I don't know why this is not working for you.

    Harold Hoffman

  12. #12

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    now worked! i think it had something to do with .Show() as with .ShowDialog() its working ok..tks anyways
    \m/\m/

  13. #13
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    .ShowDialog() stops executing the current proceedure until the form you just shown is returned. You were probably having a problem because if you use .Show(), then the form will show, but the code in the macro will continue to process, and it was reaching the end and terminating the whole thing (which includes the form you showed).

Posting Permissions

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



Click Here to Expand Forum to Full Width