How to Set VBA References

M

MarkP

Based on Rod Gill's great VBA book I have created a couple of Export to Excel
macros.

My problem that the Reference for Excel is not always setup.

I created a macro for the users that includes this code:
PrjUpdateMe.references.AddFromFile "C:\Program Files\Microsoft
Office\OFFICE11\excel.exe"

Unfortunately, the checkbox does not get checked.

Any thoughts on what I need to do?

thanks all,
MarkP
 
R

Rod Gill

Hi,

What does the PrjUpdateMe variable point to? Neither the Project or Excel
Application objects or the Project or Workbook objects have a references
collection.

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




MarkP said:
Based on Rod Gill's great VBA book I have created a couple of Export to
Excel
macros.

My problem that the Reference for Excel is not always setup.

I created a macro for the users that includes this code:
PrjUpdateMe.references.AddFromFile "C:\Program Files\Microsoft
Office\OFFICE11\excel.exe"

Unfortunately, the checkbox does not get checked.

Any thoughts on what I need to do?

thanks all,
MarkP

__________ Information from ESET Smart Security, version of virus
signature database 4805 (20100125) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4808 (20100126) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
R

Rod Gill

I know, I just wanted to check what he has pointed the variable to.

Mark, have you tried:
VBE.ActiveVBProject.References.AddFromGuid
"{00020813-0000-0000-C000-000000000046}",1,6

where 6 is Excel 2007 and 5 is Excel 2003
--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Jan De Messemaeker said:
Hi Rod,

The VBProject object has a references method for instance
VBE.ActiveVBProject.References

HTH

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf




__________ Information from ESET Smart Security, version of virus
signature database 4811 (20100127) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4811 (20100127) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

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