Anotherwayne
04-24-2023, 09:22 AM
I'm on the struggle bus. This is my first macro. I haven't coded since I made my highschool sweetheart a website back in '02. I am trying to automate a legal document. Essentially, I want the end user to open the template and have it automatically bring up a userform that inserts the answers into the document at the bookmarks. I had it all good, except that it didn't autolaunch, but if I started the macro it would do what I wanted. I also tried to figure out a way to preserve the template and have it open a new document for the end user to save. I then managed to goober it all up. Now when I open the template, it opens a new document which has the text, but not the bookmarks. So the macro can't input the userform data at the bookmarks because they do not exist.
I am a noob, so please pretend that I will have no idea what you're talking about unless you explain it like I've never coded before.
Here is my beginner level code:
This document:
Sub AutoNew()
UserForm1.Show
End Sub
Userform1:
Private Sub CommandButton1_Click()
Dim BM1 As Range
Set BM1 = ActiveDocument.Bookmarks ("BM1").Range
BM1.Text = Me.TextBox1.Value
(there are 23 more of these)
UserForm1.Hide
Me.Repaint
End Sub
Help me... I have spent 10 hours trying to write automate a single template. Save me.
I am a noob, so please pretend that I will have no idea what you're talking about unless you explain it like I've never coded before.
Here is my beginner level code:
This document:
Sub AutoNew()
UserForm1.Show
End Sub
Userform1:
Private Sub CommandButton1_Click()
Dim BM1 As Range
Set BM1 = ActiveDocument.Bookmarks ("BM1").Range
BM1.Text = Me.TextBox1.Value
(there are 23 more of these)
UserForm1.Hide
Me.Repaint
End Sub
Help me... I have spent 10 hours trying to write automate a single template. Save me.