Procyan
06-13-2005, 05:36 PM
Hello all. I would first like to complement the site designers. Vbax is one of the best layouts I have seen. Very user friendly and informative.
I have thoroughly scanned the posts and the KBase to attempt to solve this problem I have on my own but alas I cannot.
I have created a template with 10 Text Form Fields using Word 2003. The 10 fields on the document are the only thing that change on the standard form. Next I created a userform to fill in the blanks and made a macro to combine the two together. I just have a few bugs to work out and it shall be complete. What I would like to happen is when you click on the template it will load and the user will fill out the form. Then when the user clicks ok, it will save and exit. I would prefer that the user have nothing else to do because I work with a bunch of dummys that would play with it and probably mess it up.
1. I have my form auto start when you load the template. I have it coded so if they click Cancel it will unload, but I can still click on the X on the top right of my userform and get to the template below. How do I disable the X?
2. I want to protect my work, but when it is protected I cannot insert my data into the form. I realize that I need to unprotect then re-protect the Form Fields but lack the knowledge to program. I would like to learn though.
3. Upon closing the doc and exiting Word, it prompts for a save file name. If you click ok it will save and exit. If you click cancel it errors and goes to debug. What do I have to write to stop that error?
4th and final. "Thank god huh" How do I compile my project together so it will work independently. The userfrom I am using did not originally come from the template I am using it with. I guess I'm trying to say. How do I wrap it all up?
Below is the code that I wrote. Shield your eyes this is my first VBA I have written. It is probably pretty rough so any thing that would make it more professional would help also.
Private Sub AutoNew()
Master_Fill_In.Show
End Sub
Private Sub zzCancelButton_Click()
Unload Me
ActiveDocument.Close SaveChanges:=False
Application.Quit
End Sub
Private Sub zzOKButton_Click()
MonthYearT.Value = UCase(MonthYearT.Value)
PocT.Value = UCase(PocT.Value)
SwitchT.Value = UCase(SwitchT.Value)
CurrentDateT.Value = UCase(CurrentDateT.Value)
NameGradeT.Value = UCase(NameGradeT.Value)
PlacesVisitedT.Value = UCase(PlacesVisitedT.Value)
DatesT.Value = UCase(DatesT.Value)
PurposeT.Value = UCase(PurposeT.Value)
With ActiveDocument
.Bookmarks("zulutime").Range.Text = ZuluTimeT.Value
.Bookmarks("monthyear").Range.Text = MonthYearT.Value
.Bookmarks("poc").Range.Text = PocT.Value
.Bookmarks("switch").Range.Text = SwitchT.Value
.Bookmarks("contact").Range.Text = ContactT.Value
.Bookmarks("currentdate").Range.Text = CurrentDateT.Value
.Bookmarks("namegrade").Range.Text = NameGradeT.Value
.Bookmarks("placesvisited").Range.Text = PlacesVisitedT.Value
.Bookmarks("dates").Range.Text = DatesT.Value
.Bookmarks("purpose").Range.Text = PurposeT.Value
End With
Application.ScreenUpdating = True
Unload Me
.Close SaveChanges:=True
Application.Quit
End Sub
Thanks in advance,
Mike
P.S. This is a form that requires all caps.
I have thoroughly scanned the posts and the KBase to attempt to solve this problem I have on my own but alas I cannot.
I have created a template with 10 Text Form Fields using Word 2003. The 10 fields on the document are the only thing that change on the standard form. Next I created a userform to fill in the blanks and made a macro to combine the two together. I just have a few bugs to work out and it shall be complete. What I would like to happen is when you click on the template it will load and the user will fill out the form. Then when the user clicks ok, it will save and exit. I would prefer that the user have nothing else to do because I work with a bunch of dummys that would play with it and probably mess it up.
1. I have my form auto start when you load the template. I have it coded so if they click Cancel it will unload, but I can still click on the X on the top right of my userform and get to the template below. How do I disable the X?
2. I want to protect my work, but when it is protected I cannot insert my data into the form. I realize that I need to unprotect then re-protect the Form Fields but lack the knowledge to program. I would like to learn though.
3. Upon closing the doc and exiting Word, it prompts for a save file name. If you click ok it will save and exit. If you click cancel it errors and goes to debug. What do I have to write to stop that error?
4th and final. "Thank god huh" How do I compile my project together so it will work independently. The userfrom I am using did not originally come from the template I am using it with. I guess I'm trying to say. How do I wrap it all up?
Below is the code that I wrote. Shield your eyes this is my first VBA I have written. It is probably pretty rough so any thing that would make it more professional would help also.
Private Sub AutoNew()
Master_Fill_In.Show
End Sub
Private Sub zzCancelButton_Click()
Unload Me
ActiveDocument.Close SaveChanges:=False
Application.Quit
End Sub
Private Sub zzOKButton_Click()
MonthYearT.Value = UCase(MonthYearT.Value)
PocT.Value = UCase(PocT.Value)
SwitchT.Value = UCase(SwitchT.Value)
CurrentDateT.Value = UCase(CurrentDateT.Value)
NameGradeT.Value = UCase(NameGradeT.Value)
PlacesVisitedT.Value = UCase(PlacesVisitedT.Value)
DatesT.Value = UCase(DatesT.Value)
PurposeT.Value = UCase(PurposeT.Value)
With ActiveDocument
.Bookmarks("zulutime").Range.Text = ZuluTimeT.Value
.Bookmarks("monthyear").Range.Text = MonthYearT.Value
.Bookmarks("poc").Range.Text = PocT.Value
.Bookmarks("switch").Range.Text = SwitchT.Value
.Bookmarks("contact").Range.Text = ContactT.Value
.Bookmarks("currentdate").Range.Text = CurrentDateT.Value
.Bookmarks("namegrade").Range.Text = NameGradeT.Value
.Bookmarks("placesvisited").Range.Text = PlacesVisitedT.Value
.Bookmarks("dates").Range.Text = DatesT.Value
.Bookmarks("purpose").Range.Text = PurposeT.Value
End With
Application.ScreenUpdating = True
Unload Me
.Close SaveChanges:=True
Application.Quit
End Sub
Thanks in advance,
Mike
P.S. This is a form that requires all caps.