Run-time Error '1004'

G

Guest

Hi,

I have a simple function (below) that generates the following message
"Run-time Error '1004': Application-defined or object-defined error". Any
ideas on what I am doing wrong?

Thanks tons!

Public Sub Workbook_Open()

Application.VBE.ActiveVBProject.VBComponents.Item("Module1").CodeModule.ReplaceLine 1, "TEST LINE"

End Sub
 
L

Leith Ross

Hi,

I have a simple function (below) that generates the following message
"Run-time Error '1004': Application-defined or object-defined error". Any
ideas on what I am doing wrong?

Thanks tons!

Public Sub Workbook_Open()

Application.VBE.ActiveVBProject.VBComponents.Item("Module1").CodeModule.ReplaceLine 1, "TEST LINE"

End Sub

Hello BigBrother,

Have you set a reference in your VBA project to the Microsoft
Extensibility for Visual Basic? I tried several ways to reproduce your
error, but was unable. I tried no reference to the VBIDE in the
project, no module, and no prior code in the module. Error 1004 never
came up. Sorry I couldn't be more help.

Sincerely,
Leith Ross
 
C

Chip Pearson

The first thing I would look at is whether the "Trust access to the VB
project" setting is checked. Go to the Tools menu, Macros, Security, Trusted
Publisher, and check "Trust Access To Visual Basic Project".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
G

Guest

Chip.

This worked! Thanks a lot!!!

Chip Pearson said:
The first thing I would look at is whether the "Trust access to the VB
project" setting is checked. Go to the Tools menu, Macros, Security, Trusted
Publisher, and check "Trust Access To Visual Basic Project".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top