compiler error

  • Thread starter Cor van der Bliek
  • Start date
C

Cor van der Bliek

Why is this code in my module wrong?
Public Persfile As String
Public Sub AutoNew()
Set Persfile = "C:\"
UserForm.Show
End Sub

I simply want to declare a stringvariable for all my procedures.
Thanks.
 
D

Dave Lett

Hi,

I could be way off on this, but I think it has to do with using the Set
statement, so you could try simply removing that word.

Public Persfile As String
Public Sub AutoNew()
Persfile = "C:\"
UserForm.Show
End Sub

I _think_ it has to do with the Set statement, which you use to assign an
object reference, but a String is not an object.

HTH,
Dave
 
A

Andi Mayer

Why is this code in my module wrong?
Public Persfile As String
Public Sub AutoNew()
Set Persfile = "C:\"
UserForm.Show
End Sub

I simply want to declare a stringvariable for all my procedures.
Thanks.

PersFile is no Object, it's string

objects use Set, with other variables you leave the set out
 
C

Cor van der Bliek

This does the trick. Thanks for reminding.

Andi Mayer said:
PersFile is no Object, it's string

objects use Set, with other variables you leave the set out
 

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