Okay, my tool goes a little something like this:
In Excel, it creates an entryform where data is entered into various combobox and text fields.
The tool then opens Word, loads a pre-made template file with pre-defined bookmarks, then inserts the data from the entryform into those bookmarks.
My previous version used the insertion bookmarks and worked fine for when I was simply entering the data from the entryform at those points.
But for the next version, I need to insert the data INTO those bookmarks (ie a fillable form) so that I can then recall the data from the Word file back into the Excel tool.
Make sense so far?
Using my old code doesn't work. I receive an error message: Run-time error '438': Object doesn't support this property or method.
I've tried all sorts of combinations of code to get this to work and still not getting it right. Clearly, I'm not understanding the error message.
My code looks a little something like this:
--------------------------------------------------------------------------------
'
' Open the Word Program and load the TcubedCVR-newertoolform.dot template.
'
Set wrd = CreateObject("Word.application")
wrd.Visible = True
Set CVR = wrd.documents.Add("TcubedCVR-newertoolform.dot")
CVR.Protect Type:=2, Password:="12345"
'
' Store form fields into Word bookmarks
'
CVR.Bookmarks("TcubedTchr").Text = TcubedTchr
CVR.Bookmarks("School").Range = School
CVR.Bookmarks("VisitDate").Range.Text = Date
CVR.Bookmarks("VisitTime").Range.Text = Time
--------------------------------------------------------------------------------
You might ask yourself why am I protecting the document. Well, if I don't the text inserted replaces the bookmark. But when I protect it so that the file is a fillable form, I can manually insert text/data into the bookmarks without losing them. So I'm trying to automate that process by having the tool insert into the bookmarks the data from the fields.
Any help is appreciated! Muchos Danke!!
In Excel, it creates an entryform where data is entered into various combobox and text fields.
The tool then opens Word, loads a pre-made template file with pre-defined bookmarks, then inserts the data from the entryform into those bookmarks.
My previous version used the insertion bookmarks and worked fine for when I was simply entering the data from the entryform at those points.
But for the next version, I need to insert the data INTO those bookmarks (ie a fillable form) so that I can then recall the data from the Word file back into the Excel tool.
Make sense so far?
Using my old code doesn't work. I receive an error message: Run-time error '438': Object doesn't support this property or method.
I've tried all sorts of combinations of code to get this to work and still not getting it right. Clearly, I'm not understanding the error message.
My code looks a little something like this:
--------------------------------------------------------------------------------
'
' Open the Word Program and load the TcubedCVR-newertoolform.dot template.
'
Set wrd = CreateObject("Word.application")
wrd.Visible = True
Set CVR = wrd.documents.Add("TcubedCVR-newertoolform.dot")
CVR.Protect Type:=2, Password:="12345"
'
' Store form fields into Word bookmarks
'
CVR.Bookmarks("TcubedTchr").Text = TcubedTchr
CVR.Bookmarks("School").Range = School
CVR.Bookmarks("VisitDate").Range.Text = Date
CVR.Bookmarks("VisitTime").Range.Text = Time
--------------------------------------------------------------------------------
You might ask yourself why am I protecting the document. Well, if I don't the text inserted replaces the bookmark. But when I protect it so that the file is a fillable form, I can manually insert text/data into the bookmarks without losing them. So I'm trying to automate that process by having the tool insert into the bookmarks the data from the fields.
Any help is appreciated! Muchos Danke!!