View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Creating a path to save a file

in addition, his string has a space in front of username: \ username\

Personally, if I were OldJay, I'd choose another name for variable username
- to prevent confusion when reading the code. I don't know about you, but I
shy away from using anything closely resembling a property or method name for
any of my own variables or constants.

Hey, OldJay! how ya' doin'??

"Rick Rothstein (MVP - VB)" wrote:

I am trying to save a file to a users file on a server I can't get the path
right

Dim username As String
username = Application.username
NUMBERSAVE = Range("AB2")

If Application.username = "jauld" Then

QUOTENUMBER1 = InputBox("Please enter QUOTE file name to save to
Server3", "The Company", "\\server3\jobs\ username\" & NUMBERSAVE)

QUOTE = QUOTENUMBER1 & ".XLS"
ActiveWorkbook.SaveAs Filename:=QUOTE

How do a specify the correct path?


You have the variable 'username' inside the quote marks... VB thinks that is
a bunch of characters just like the rest of the characters between the quote
marks. You need to concatenate the username to the rest of the text so that
VB can substitute what you assigned to it. Try it this way...

"\\server3\jobs\" & username & "\" & NUMBERSAVE

Rick