Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

License error with CreateObject 1

Status
Not open for further replies.

RoShell

Technical User
Jan 19, 2009
3
US
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

 
I didn't use Office 2007 for long, took to many resources when I had it availbale at a previous job. In office 2003 your createobject looks fine to me. Is it possible you are using a copy of Office 2007 that is in a 120 day trail period and isn't fully licensed?

Otherwise a workaround is to use the shell command to open word first....

Code:
strWinwordPathandFile = "winword.exe" 'you will need to find winword.exe and make a full path
shell(strWinwordPathandFile) 'tells windows to run the parameter
sleep 200 'code continues executing without waiting for OS response, wait 200 milliseconds

Honestly I'd trap the error and conditionally open word but this should get you started.
 
Thanks much for your response! Your suggestion worked!

I've been working with this copy of Office(which came installed on a Dell laptop) for about 10 months and have 'assumed' (we all know what that means) that it was fully licensed...

I do need to work in more error handling as I'm still getting errors and have other issues with this piece of code - but it opens the template now whether Word has been opened previously or not. I'll continue working on it and see what I find.

Thanks again. You made my day!

-r
 
One other thought occured to me... Do you have a reference set to Word (in your code go to the tools menu and references and check the one for Word; probably Microsoft Word .... )?

It occurs to me that they MAY have made Access 2007 'smarter' by not requiring it to have a reference set if the application is open. I doubt it but worth checking. If you don't have a reference, you can add it and try it without shell.
 
No, didn't resolve the license issue, however it DID resolve the other errors I was getting and enabled the bookmark piece of the code to work - which I hadn't been able to get to work previously - THANK YOU!

Here's what I discovered - if I use JUST the CreateObject() line, it will start the Word application if it is not already running. If Word is already running, CreateObject() will open the designated template as a new document - all without error. So this appears to work fine - as long as I'm not missing something I can't see....

If I try to use the GetObject()piece, it only works if Word is already running, if not, I get the license error - so clearly I'm not using it in the right place.

Thanks again for the tip about the Reference Library - that saved me hours of frustration trying to get the bookmarks to work.

-r
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top