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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX component can't create object 1

Status
Not open for further replies.

robwistar

Technical User
Jun 5, 2003
29
0
0
US
"ActiveX component can't create object"

I get that error when I run this code:

Dim hyperPackList As New Hyperlink
hyperPackList.Address = strNewFileName


It seems to crash on the second line there. If I comment out that second line, it crashes on the next line:

hyperPackList.TextToDisplay = strSampletext

I looked here:
Cause 1: didn't help
Cause 2: didn't notice that anything said missing
Cause 3: no utility stuff was checked
Cause 4: i'm an administrator
Cause 5: i am not using a wizard and hesitate to reinstall access (i have read on this forum about people having nightmares after reinstalling access)
Cause 6: i don't know what they are talking about so i assume it doesn't apply to me.

Thanks in advance for the help!

Rob
 
Hi robwistar,

Not sure what you're trying to do, but this works assuming "hyperPackList" is a label.

Dim strNewFileName As String
Dim hyperPackList As New Hyperlink
strNewFileName = " Me!hyperPackList.HyperlinkAddress = strNewFileName
Me!hyperPackList.Caption = strNewFileName

Get back to us with a more detailed explanation of what you are trying to achieve if this doesn't help.

Bill
 
billpower --

thanks for getting back. when i tried your code, I got the error:

"Microsoft can't find the field 'hyperPackList' referred to in your expression"

I don't know why it was looking for a field, but I am also not familiar with the use of 'Me!', so I tried removing that. Then I got the error:

"Method or data member not found"

and it highlighted the word HyperlinkAddress. I looked through the help files and it *seems* like the methods I need to use are .Address and .TextToDisplay (but it's not working so I could be wrong here :)

Thoughts?

Rob
 
I have an idea what the problem may be, but I don't know what to do about it. From the VB help files:

"You can use the Address property to specify or determine the path to an object, document, Web page or other destination for a Hyperlink object associated with a command button, image control, or label control."

I just made the hyperlink, and didn't associate it with a command button, image control, or label control. It will be sitting in a hyperlink field of one of my tables. Could this be the source of my problem?

I just want to make a hyperlink and stick in in a table.

Thanks!

Rob
 
Doh! I just realized that that you said that that code "works assuming 'hyperPackList' is a label."

I am a bit new to Access ... how can hyperPackList be a label if you dimensioned it as a hyperlink?

I have a shipment table with one of the fields being hyperlinks to the corresponding packing list (Word document). hyperPackList is supposed to be the hyperlink to the Word document. I have been creating them manually but would like to create them programatically.

Rob
 
Hi robwistar,

The example I gave does work for a label. It is just an example.

I should really have asked exactly what it is you are trying to do.

Your question doesn't say how or where you are going to get this hyperlink, from the web, a folder on your PC a Form or Report etc in a DB.

Also what do you want to do with the hyperlink, just go to it, store it in a table, store it in a list ect.

If you can be a bit clearer about what you want to do and how, I or someone else will probably be able to supply a "better" example for you.

All the best

Bill
 
Thanks Bill, I will try to be more clear.

Every time we make a shipment, we make up a packing slip. I have a table in my Access database that stores each shipment. It includes stuff like an id# and the date, etc. It also includes a hyperlink field that contains a hyperlink to the packing list (word document on the hard drive) that corresponds to the shipment. So every shipment has its own record complete with hyperlink to a packing list stored on the computer (but not embedded in the database).

As it is right now, I have to manually make the packing list, go into the table and enter all this information that seems like it could be easily automated. I am writing a small app to do just that.

My current code copies a packing list template that I made and gives it a unique name based on the date. It then creates a new record, inserts the shipment date, and (should) insert a hyperlink to that newly created packing list into the hyperlink field of the new record. Here's what I have:


Dim strMonth As String
Dim strDay As String
Dim strYr As String
Dim strNewPlFilename As String

strMonth = returnMoDayYr(0)
'returns month
strDay = returnMoDayYr(1)
'returns day
strYr = returnMoDayYr(2)
'returns year

'stores the file name and path of the soon-to-be created packinglist
strNewPlFilename = "C:\Documents and Settings\carter\My Documents\packing lists\PL." + strMonth + _
"." + strDay + "." + strYear + ".doc"

FileCopy "C:\Documents and Settings\carter\My Documents\packing lists\Packing List Template.doc", strNewPlFilename

Dim hyperPackList As New Hyperlink

hyperPackList.Address = strNewPlFilename
hyperPackList.TextToDisplay = "PL." + strMonth + "." + strDay + "." + strYear
Forms!ShipInternalForm![Packing List] = hyperPackList
hyperPackList.Follow
'opens new packing list for editing

[/i]

So at the end the table record should be complete and the pacing list should be open on the screen for editing. Later I will automate adding text to the packing list, but I need to get through this first.

Thanks!

Rob
 
oh, and the error "ActiveX component can't create object" seems to pop up when you try to set a property of the hyperlink, i.e.: hyperPackList.Adress = strNewPLFileName

Thanks!

Rob
 
Hi robwistar,

The method you were trying to use will only work with a label, image or command button as far as I know, not with a text box.

The edited code below should work as you intended, the Text Box's Is Hyperlink property should be set to yes and the Field in the underlying Table should be Hyperlink.

Dim strMonth As String
Dim strDay As String
Dim strYr As String
Dim strNewPlFilename As String

strMonth = returnMoDayYr(0) 'returns month
strDay = returnMoDayYr(1) 'returns day
strYr = returnMoDayYr(2) 'returns year

strNewPlFilename = "C:\Documents and Settings\carter\My Documents\packing lists\PL." + strMonth + _
"." + strDay + "." + strYr + ".doc"
FileCopy "C:\Documents and Settings\carter\My Documents\packing lists\Packing List Template.doc", strNewPlFilename

Forms!ShipInternalForm![Packing List].SetFocus
Forms!ShipInternalForm![Packing List] = "PL." + strMonth + "." + strDay + "." + strYr & "#" & strNewPlFilename
Application.FollowHyperlink strNewPlFilename, , True

Note the use of the hash "#" to identify the Hyperlink Address.

Also you were incorrectly using strYr as strYear.

All the best

Bill
 
Bill --

Thanks for that. I couldn't find documentation in either of my books for that.

You're a champion. Star for you!

(and good eye on the typo) [blush]

Rob
 
Hi robwistar,

Thanks for the star, glad we got there in the end.

I feel so sorry for you newbies today, when I started with Access 1, 2 and '95 we got very good manuals explaining every method etc available in the respective versions along with our floppies, examples in Help were more basic than '97, 2000 etc. quite often actually usable.

Rarely do I find an example in Help actually helpful or useful these days. I think it's a deliberate ploy of "Bill Gates" to get us all to pay highly exorbitant rates to use his help line.

Sorry to go on, Bill Gates is one of my pet hates. Anyway the bottom line is thank goodness for Tek-Tips and that also I understand your dilemma when looking for documentation on methods that you don't quite understand.

Hope we can help agian in the future.

Bill (Power)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top