Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
Macro for Word
Hi Experts,
I am designing a form in word 2003. Want to make a macro which does the following function. This is for a report generated after I finish the Instrument installation. At one customer site, we will install one to many instruments. I used the Form tool, to put the drop down menu for Quantity of instruments. Macro i need should be able to create new text fields for entering the serial number of instruments depending on the quantity of instruments selected above. eg: If I select Instrument A is of Qty 2, then 2 text fields should pop up below in the word document to enter the serial number of that. Later I should be able to save the document and print out. Can some one help me with this or if there is any other way, kindly help suggest. Thanks and Regards VSK |
#2
Posted to microsoft.public.word.newusers
|
|||
|
|||
Macro for Word
Yeah, sort of.
If you have your dropdown and then at least one text field (assuming you will always have at least one SN to enter) then you could add a bookmark "AddFields" after the text field and run this code on exit from the DropDown: Sub AddFields() ActiveDocument.Unprotect Dim oFF As FormFields Set oFF = ActiveDocument.FormFields Dim i As Long For i = 2 To oFF("DropDown1").DropDown.Value ActiveDocument.Bookmarks("AddFields").Range.Insert After " " oFF.Add ActiveDocument.Bookmarks("AddFields").Range, wdFieldFormTextInput Next i ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub On Feb 2, 9:52 am, VSK wrote: Hi Experts, I am designing a form in word 2003. Want to make a macro which does the following function. This is for a report generated after I finish the Instrument installation. At one customer site, we will install one to many instruments. I used the Form tool, to put the drop down menu for Quantity of instruments. Macro i need should be able to create new text fields for entering the serial number of instruments depending on the quantity of instruments selected above. eg: If I select Instrument A is of Qty 2, then 2 text fields should pop up below in the word document to enter the serial number of that. Later I should be able to save the document and print out. Can some one help me with this or if there is any other way, kindly help suggest. Thanks and Regards VSK |
#3
Posted to microsoft.public.word.newusers
|
|||
|
|||
Macro for Word
Hi Sir,
Thankyou very much for your valuable feedback. I am totally new to the macros and tried to copy the commands in the macro and execute it. first I opened the word, created a List box (bookmark as dropdown1) using formfield. then created a textbox with bookmark as text 1. Then below the text1 i inserted the Bookmark "Addfields" using the Insert command. After this I protected the document and selected the number 3. When I exited nothing happened. But when I went and click the Text1, another text box was created right below text 1. When I click the Text 2, another text box was created. In short, it was creating more text box rather than required everytime i click it. Can you please give your expert advice. thanks and regards VSK "Greg Maxey" wrote: Yeah, sort of. If you have your dropdown and then at least one text field (assuming you will always have at least one SN to enter) then you could add a bookmark "AddFields" after the text field and run this code on exit from the DropDown: Sub AddFields() ActiveDocument.Unprotect Dim oFF As FormFields Set oFF = ActiveDocument.FormFields Dim i As Long For i = 2 To oFF("DropDown1").DropDown.Value ActiveDocument.Bookmarks("AddFields").Range.Insert After " " oFF.Add ActiveDocument.Bookmarks("AddFields").Range, wdFieldFormTextInput Next i ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub On Feb 2, 9:52 am, VSK wrote: Hi Experts, I am designing a form in word 2003. Want to make a macro which does the following function. This is for a report generated after I finish the Instrument installation. At one customer site, we will install one to many instruments. I used the Form tool, to put the drop down menu for Quantity of instruments. Macro i need should be able to create new text fields for entering the serial number of instruments depending on the quantity of instruments selected above. eg: If I select Instrument A is of Qty 2, then 2 text fields should pop up below in the word document to enter the serial number of that. Later I should be able to save the document and print out. Can some one help me with this or if there is any other way, kindly help suggest. Thanks and Regards VSK |
#4
Posted to microsoft.public.word.newusers
|
|||
|
|||
Macro for Word
You shouldn't be using the control toolbox to enter activeX controls. Use
the ViewToolbars and open the Forms toolbar. Insert a dropdown field (it will automatically be called dropdown1 by defualt. Add your numbers (e.g., 1, 2, 3, 4, 5, etc). Insert the macro text I provided you in the VBA project for the document. Back in the document, double click the formfield and set AddFields macro to run on exit. Insert a text field after the dropdown, insert a bookmark named "AddField" after the text field. Protect the document and Bob's your uncle. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. VSK wrote: Hi Sir, Thankyou very much for your valuable feedback. I am totally new to the macros and tried to copy the commands in the macro and execute it. first I opened the word, created a List box (bookmark as dropdown1) using formfield. then created a textbox with bookmark as text 1. Then below the text1 i inserted the Bookmark "Addfields" using the Insert command. After this I protected the document and selected the number 3. When I exited nothing happened. But when I went and click the Text1, another text box was created right below text 1. When I click the Text 2, another text box was created. In short, it was creating more text box rather than required everytime i click it. Can you please give your expert advice. thanks and regards VSK "Greg Maxey" wrote: Yeah, sort of. If you have your dropdown and then at least one text field (assuming you will always have at least one SN to enter) then you could add a bookmark "AddFields" after the text field and run this code on exit from the DropDown: Sub AddFields() ActiveDocument.Unprotect Dim oFF As FormFields Set oFF = ActiveDocument.FormFields Dim i As Long For i = 2 To oFF("DropDown1").DropDown.Value ActiveDocument.Bookmarks("AddFields").Range.Insert After " " oFF.Add ActiveDocument.Bookmarks("AddFields").Range, wdFieldFormTextInput Next i ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub On Feb 2, 9:52 am, VSK wrote: Hi Experts, I am designing a form in word 2003. Want to make a macro which does the following function. This is for a report generated after I finish the Instrument installation. At one customer site, we will install one to many instruments. I used the Form tool, to put the drop down menu for Quantity of instruments. Macro i need should be able to create new text fields for entering the serial number of instruments depending on the quantity of instruments selected above. eg: If I select Instrument A is of Qty 2, then 2 text fields should pop up below in the word document to enter the serial number of that. Later I should be able to save the document and print out. Can some one help me with this or if there is any other way, kindly help suggest. Thanks and Regards VSK |
#5
Posted to microsoft.public.word.newusers
|
|||
|
|||
Macro for Word
Hi Sir,
I didnt use a control toolbox, instead i said the same way as u have mentioned. But as I said, before, after I select and exit the dropdown menu, nothing pops up. But then when I click the text 1 , the second text box pops up. Even if the selection in the drop down box is 3, the text box creation continues. This is what confuses me. Thanks and regarrds VSK "Greg Maxey" wrote: You shouldn't be using the control toolbox to enter activeX controls. Use the ViewToolbars and open the Forms toolbar. Insert a dropdown field (it will automatically be called dropdown1 by defualt. Add your numbers (e.g., 1, 2, 3, 4, 5, etc). Insert the macro text I provided you in the VBA project for the document. Back in the document, double click the formfield and set AddFields macro to run on exit. Insert a text field after the dropdown, insert a bookmark named "AddField" after the text field. Protect the document and Bob's your uncle. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. VSK wrote: Hi Sir, Thankyou very much for your valuable feedback. I am totally new to the macros and tried to copy the commands in the macro and execute it. first I opened the word, created a List box (bookmark as dropdown1) using formfield. then created a textbox with bookmark as text 1. Then below the text1 i inserted the Bookmark "Addfields" using the Insert command. After this I protected the document and selected the number 3. When I exited nothing happened. But when I went and click the Text1, another text box was created right below text 1. When I click the Text 2, another text box was created. In short, it was creating more text box rather than required everytime i click it. Can you please give your expert advice. thanks and regards VSK "Greg Maxey" wrote: Yeah, sort of. If you have your dropdown and then at least one text field (assuming you will always have at least one SN to enter) then you could add a bookmark "AddFields" after the text field and run this code on exit from the DropDown: Sub AddFields() ActiveDocument.Unprotect Dim oFF As FormFields Set oFF = ActiveDocument.FormFields Dim i As Long For i = 2 To oFF("DropDown1").DropDown.Value ActiveDocument.Bookmarks("AddFields").Range.Insert After " " oFF.Add ActiveDocument.Bookmarks("AddFields").Range, wdFieldFormTextInput Next i ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub On Feb 2, 9:52 am, VSK wrote: Hi Experts, I am designing a form in word 2003. Want to make a macro which does the following function. This is for a report generated after I finish the Instrument installation. At one customer site, we will install one to many instruments. I used the Form tool, to put the drop down menu for Quantity of instruments. Macro i need should be able to create new text fields for entering the serial number of instruments depending on the quantity of instruments selected above. eg: If I select Instrument A is of Qty 2, then 2 text fields should pop up below in the word document to enter the serial number of that. Later I should be able to save the document and print out. Can some one help me with this or if there is any other way, kindly help suggest. Thanks and Regards VSK |
#6
Posted to microsoft.public.word.newusers
|
|||
|
|||
Macro for Word
Send me your document and I will look at it this evening if I get a
chance. (delete the CAPS) -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. VSK wrote: Hi Sir, I didnt use a control toolbox, instead i said the same way as u have mentioned. But as I said, before, after I select and exit the dropdown menu, nothing pops up. But then when I click the text 1 , the second text box pops up. Even if the selection in the drop down box is 3, the text box creation continues. This is what confuses me. Thanks and regarrds VSK "Greg Maxey" wrote: You shouldn't be using the control toolbox to enter activeX controls. Use the ViewToolbars and open the Forms toolbar. Insert a dropdown field (it will automatically be called dropdown1 by defualt. Add your numbers (e.g., 1, 2, 3, 4, 5, etc). Insert the macro text I provided you in the VBA project for the document. Back in the document, double click the formfield and set AddFields macro to run on exit. Insert a text field after the dropdown, insert a bookmark named "AddField" after the text field. Protect the document and Bob's your uncle. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. VSK wrote: Hi Sir, Thankyou very much for your valuable feedback. I am totally new to the macros and tried to copy the commands in the macro and execute it. first I opened the word, created a List box (bookmark as dropdown1) using formfield. then created a textbox with bookmark as text 1. Then below the text1 i inserted the Bookmark "Addfields" using the Insert command. After this I protected the document and selected the number 3. When I exited nothing happened. But when I went and click the Text1, another text box was created right below text 1. When I click the Text 2, another text box was created. In short, it was creating more text box rather than required everytime i click it. Can you please give your expert advice. thanks and regards VSK "Greg Maxey" wrote: Yeah, sort of. If you have your dropdown and then at least one text field (assuming you will always have at least one SN to enter) then you could add a bookmark "AddFields" after the text field and run this code on exit from the DropDown: Sub AddFields() ActiveDocument.Unprotect Dim oFF As FormFields Set oFF = ActiveDocument.FormFields Dim i As Long For i = 2 To oFF("DropDown1").DropDown.Value ActiveDocument.Bookmarks("AddFields").Range.Insert After " " oFF.Add ActiveDocument.Bookmarks("AddFields").Range, wdFieldFormTextInput Next i ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub On Feb 2, 9:52 am, VSK wrote: Hi Experts, I am designing a form in word 2003. Want to make a macro which does the following function. This is for a report generated after I finish the Instrument installation. At one customer site, we will install one to many instruments. I used the Form tool, to put the drop down menu for Quantity of instruments. Macro i need should be able to create new text fields for entering the serial number of instruments depending on the quantity of instruments selected above. eg: If I select Instrument A is of Qty 2, then 2 text fields should pop up below in the word document to enter the serial number of that. Later I should be able to save the document and print out. Can some one help me with this or if there is any other way, kindly help suggest. Thanks and Regards VSK |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Form Generaters in Word | Microsoft Word Help | |||
macro produces error message | Microsoft Word Help | |||
Macro Button Won't Stay on Toolbar | Microsoft Word Help | |||
Possible bug when recording a Word Macro | Microsoft Word Help | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge |