May 10th, 2005, 10:46 AM
#1
Thread Starter
PowerPoster
New to VBA and have question
I am trying to automate a Word document. I wish to build a form using VBA and when opening the document, I wish the form to be displayed where I can enter values...close the form...and populate the Word document with the entered values.
Can someone start me out on the right track as to what commands and events need to be used?
Thanks,
Blake
May 10th, 2005, 11:32 AM
#2
Re: New to VBA and have question
Are you wanting to load the UserForm manually?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 10th, 2005, 11:39 AM
#3
Thread Starter
PowerPoster
Re: New to VBA and have question
Rob,
I guess I want the form to load when the document is opened and then have an command button that would allow me to close/hide the form.
Blake
May 10th, 2005, 11:43 AM
#4
Re: New to VBA and have question
You can add a UserForm to your document in the VBA IDE. Click Insert > UserForm. Then build it as you would VB6 form.
Are you needing to populate the form from a db or something?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 10th, 2005, 12:17 PM
#5
Thread Starter
PowerPoster
Re: New to VBA and have question
Rob,
I have actually done this process where I inserted a UserForm, however, I'm just not sure how to associate it with the Word Document.
May 10th, 2005, 12:29 PM
#6
Re: New to VBA and have question
Heres a sample of how to transfer textbox text to a document.
Also, it starts up the userform upon document open. Enable your macros.
Attached Files
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 10th, 2005, 12:38 PM
#7
Thread Starter
PowerPoster
Re: New to VBA and have question
Rob,
That was a big help, however, one more question regarding predefined fields on the Word Document. How do place a form value into a predefined field already on the document?
Thanks,
Blake
May 10th, 2005, 12:47 PM
#8
Re: New to VBA and have question
You can create a bookmark in the place where you want to insert the data. Then refer to the BM's .Range.Text = Userform.Textbox1.Text, etc.
You can also use the .Find method and replace the found text with textbox contents.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 10th, 2005, 12:50 PM
#9
Thread Starter
PowerPoster
Re: New to VBA and have question
Easier said than done bro....but I'll give it a shot.
Thanks,
Blake
May 10th, 2005, 12:56 PM
#10
Re: New to VBA and have question
True, but there is already code in this forum to do it, so it will only take a few searches.
I remember assisting in a thread on .Find
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 10th, 2005, 01:01 PM
#11
Thread Starter
PowerPoster
Re: New to VBA and have question
Thanks for your help bro!!!
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width