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?
Printable View
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?
I just wrote this macro. It works fine for me. Is this something like what you are having trouble with?
VB Code:
Public Sub macTRIS001() Dim i As Integer = InputBox("How many times?", "Write the letter 'A'", 0) Dim x As Integer For x = 1 To i DTE.ActiveDocument.Selection.Text = "A" Next End Sub
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?
the way seems to be vs.net addins..anyone had worked in anything of this? any one has any experience/thoughs about this?
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
as ive said above everytime i try to instantiate a class it just freezes up.......that doesnt happen to u?
Hi
My Forms work fine in a macro. If you post your macro I'll try it out.
Harold Hoffman
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!
Hi
Yes. I am talking about macros not addins. Where is your Form class defined?
Harold Hoffman
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
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
now worked! i think it had something to do with .Show() as with .ShowDialog() its working ok..tks anyways
.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).