PDA

View Full Version : Name VB not working



Emoncada
01-20-2008, 12:35 PM
I found some vb that I modified to my need and it's giving me an error.

Name "C:\WIP\" & Range("$K$3") & "\" & Range("$K$5") & "\" & Range("$B$6") & ".xls" As "C:\Needs Approval\" & ns & "\" & Range("$B$6") & ".xls"


Am I not allowed to use Range?

My Goal is to move the file from one folder to another.

Bob Phillips
01-20-2008, 12:36 PM
You don't need the $ and you should qualify the property, .Value, but the rest looks fine.

Emoncada
01-20-2008, 12:41 PM
It's giving me

Run-time error '75'
Path/file access error

Emoncada
01-20-2008, 12:45 PM
This is the entire code and this is in a userform

Private Sub CmdSignOff_Click()
Dim ns As String
'Put In Folder For Angela
If Me.ButtonAngela.Value = True Then ns = Me.ButtonAngela.Caption
'Put In Folder For Cassandra
If Me.ButtonCassandra.Value = True Then ns = Me.ButtonCassandra.Caption
'Put In Folder For Emilio
If Me.ButtonEmilio.Value = True Then ns = Me.ButtonEmilio.Caption
'Put In Folder For Eric
If Me.ButtonEric.Value = True Then ns = Me.ButtonEric.Caption
'Put In Folder For Howard
If Me.ButtonHoward.Value = True Then ns = Me.ButtonHoward.Caption
'Put In Folder For Julie
If Me.ButtonJulie.Value = True Then ns = Me.ButtonJulie.Caption
'Put In Folder For Latoria
If Me.ButtonLatoria.Value = True Then ns = Me.ButtonLatoria.Caption
'Put In Folder For Marvin
If Me.ButtonMarvin.Value = True Then ns = Me.ButtonMarvin.Caption
'Put In Folder For Neddy
If Me.ButtonNeddy.Value = True Then ns = Me.ButtonNeddy.Caption
'Put In Folder For Patty
If Me.ButtonPatty.Value = True Then ns = Me.ButtonPatty.Caption
'Put In Folder For Simone
If Me.ButtonSimone.Value = True Then ns = Me.ButtonSimone.Caption
'Put In Folder For Steve
If Me.ButtonSteve.Value = True Then ns = Me.ButtonSteve.Caption

With Worksheets("Equipment Tracking")

Name "C:\WIP\" & Range("K3").Value & "\" & Range("K5").Value & "\" & Range("B6").Value & ".xls" As "C:\Needs Approval\" & ns & "\" & Range("B6").Value & ".xls"

End With
End Sub

hope that helps

ProteanBeing
01-20-2008, 01:00 PM
I don't if this will work but try + instead of &

Also there should be a . before Name

Emoncada
01-20-2008, 01:07 PM
The & should work and I am pretty sure no . should go before Name

Emoncada
01-20-2008, 01:12 PM
I tried the + instead of the & symbol it still gave me the same error.

ProteanBeing
01-20-2008, 01:14 PM
The . must be in front of each range

Emoncada
01-20-2008, 01:49 PM
Could this be failing because it's the active file i am trying to move?
If so How can I make that happen?

ProteanBeing
01-20-2008, 01:53 PM
Name "C:\WIP\" & .Range("K3").Value & "\" & .Range("K5").Value & "\" & .Range("B6").Value & ".xls" As "C:\Needs Approval\" & ns & "\" & .Range("B6").Value & ".xls"

Try replacing the name line with this

Emoncada
01-20-2008, 01:58 PM
No That didn't work.

ProteanBeing
01-20-2008, 02:15 PM
Could this be failing because it's the active file i am trying to move?
If so How can I make that happen?

Do a save as to the new location, then delete (kill function) the old file.

Emoncada
01-20-2008, 02:44 PM
can u tell me how I can do that.

Emoncada
01-21-2008, 06:13 AM
Does anyone know how I can complete this task without using the kill action?

ProteanBeing
01-21-2008, 02:21 PM
why do you not want to use kill?

Emoncada
01-21-2008, 02:38 PM
I set it up with the Kill function but I liked the Name function better. I don't like the fact that it deletes any file. I preffered a move.