First, I'm a newbie and thanks to BuilderSpec, et al for the code I'm using.
When calling the function below, I get the following error
"The expression on-click you entred as the event property setting produced the following error: License information for this component not found. You do not have an appropriate license to use this functionality in the design environment."
Which occurs after the following line:
Set objWord = CreateObject("Word.Application")
When Word is not open. When Word is already open, the appropriate document opens using the template desired.
I'm using Vista Home and Office 2007 Pro. The entire function is below:
Public Function CreateWordLetter(strDocPath As String)
'On Error Resume Next
'If there is no document then exit
If IsNull(strDocPath) Or strDocPath = "" Then
Exit Function
End If
Dim objWord As Object
Dim PrintResponse
'run hourglass while opening word
'DoCmd.Hourglass True
'create reference to Word Object
Set objWord = GetObject(, "Word.Application")
'if Word is not running, open the application:
If Err.Number <> 0 Then
Set objWord = CreateObject("Word.Application")
End If
'Make sure Word instance is visible:
objWord.Visible = True
'use an existing template
objWord.Documents.Add Template:=strDocPath, NewTemplate:=False
objWord.Activate
'Word is open, now enter data
With objWord.Selection
.GoTo what:=wdGoToBookmark, Name:="CFN"
.TypeText CStr(Forms!frmAIP![First Name])
End With
'find out if the user would like to print the document
'at this time.
PrintResponse = MsgBox("Print this document?", vbYesNo)
If PrintResponse = vbYes Then
objWord.ActiveDocument.PrintOut Background:=False
End If
'release all objects
'DoCmd.Hourglass False
Set objWord = Nothing
End Function
Any ideas, tips, suggestions appreciated.
-RoShell
When calling the function below, I get the following error
"The expression on-click you entred as the event property setting produced the following error: License information for this component not found. You do not have an appropriate license to use this functionality in the design environment."
Which occurs after the following line:
Set objWord = CreateObject("Word.Application")
When Word is not open. When Word is already open, the appropriate document opens using the template desired.
I'm using Vista Home and Office 2007 Pro. The entire function is below:
Public Function CreateWordLetter(strDocPath As String)
'On Error Resume Next
'If there is no document then exit
If IsNull(strDocPath) Or strDocPath = "" Then
Exit Function
End If
Dim objWord As Object
Dim PrintResponse
'run hourglass while opening word
'DoCmd.Hourglass True
'create reference to Word Object
Set objWord = GetObject(, "Word.Application")
'if Word is not running, open the application:
If Err.Number <> 0 Then
Set objWord = CreateObject("Word.Application")
End If
'Make sure Word instance is visible:
objWord.Visible = True
'use an existing template
objWord.Documents.Add Template:=strDocPath, NewTemplate:=False
objWord.Activate
'Word is open, now enter data
With objWord.Selection
.GoTo what:=wdGoToBookmark, Name:="CFN"
.TypeText CStr(Forms!frmAIP![First Name])
End With
'find out if the user would like to print the document
'at this time.
PrintResponse = MsgBox("Print this document?", vbYesNo)
If PrintResponse = vbYes Then
objWord.ActiveDocument.PrintOut Background:=False
End If
'release all objects
'DoCmd.Hourglass False
Set objWord = Nothing
End Function
Any ideas, tips, suggestions appreciated.
-RoShell