activate PublicConst

  • Thread starter Thread starter MD
  • Start date Start date
M

MD

I have a workbook AA.xls that contains an Auto_Open sub
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("Public")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
Dim FName As String
FName = "c:\mam97\code.txt"
ThisWorkbook.VBProject.VBComponents.Import FName
End Sub

The content of the txt file is:

Attribute VB_Name = "Publique"
Public Const Drive = "c:"

When the auto_open execute it does not activate my Public Const "DRIVE" and
assign it the value of C: !!

Any clues????

Regards Michel
 
Hi Michel,
"Drive" is a VBA keyword and trying to redefine it into a constant may be
causing the problem.
Try MyDrive.
 
Back
Top