PC Review


Reply
Thread Tools Rate Thread

Creating a path to save a file

 
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      5th Aug 2007
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?

oldjay


 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      5th Aug 2007
>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

 
Reply With Quote
 
=?Utf-8?B?SkxhdGhhbQ==?=
Guest
Posts: n/a
 
      5th Aug 2007
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
>
>

 
Reply With Quote
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      5th Aug 2007
Hi - I want to thank you again for all the work you did for me. I copied the
code to my program as follows

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

and get a compile error

"JLatham" wrote:

> 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
> >
> >

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      5th Aug 2007
> Hi - I want to thank you again for all the work you did for me. I copied
> the
> code to my program as follows
>
> QUOTENUMBER1 = InputBox("Please enter QUOTE file name to save to Server3",
> "The Company", "\\server3\jobs\" & username & "\" & NUMBERSAVE
>
> and get a compile error


Did you copy it as it is shown (on 2 lines)? If so, make it one line or use
this properly "continued" statement...

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

And while it is probably just a typo on your part, you left out the closing
parenthesis on your posted line of code.

If this does not solve the problem... Are any lines being highlighted, or
any error numbers being displayed, when the compile error is generated? If
so, tell us what they are.

Rick

 
Reply With Quote
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      6th Aug 2007
Thanks Every thing is working correctly

oldjay

"Rick Rothstein (MVP - VB)" wrote:

> > Hi - I want to thank you again for all the work you did for me. I copied
> > the
> > code to my program as follows
> >
> > QUOTENUMBER1 = InputBox("Please enter QUOTE file name to save to Server3",
> > "The Company", "\\server3\jobs\" & username & "\" & NUMBERSAVE
> >
> > and get a compile error

>
> Did you copy it as it is shown (on 2 lines)? If so, make it one line or use
> this properly "continued" statement...
>
> QUOTENUMBER1=InputBox("Please enter QUOTE file name to save to Server3", _
> "The Company", "\\server3\jobs\" & UserName & "\" & NUMBERSAVE)
>
> And while it is probably just a typo on your part, you left out the closing
> parenthesis on your posted line of code.
>
> If this does not solve the problem... Are any lines being highlighted, or
> any error numbers being displayed, when the compile error is generated? If
> so, tell us what they are.
>
> Rick
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Path validation without file creating functions Mohammad Omer Microsoft VC .NET 7 24th Sep 2009 09:06 PM
Creating a path and opening a PDF File Chez Microsoft Access VBA Modules 2 28th Oct 2008 09:49 PM
Creating Excel file that points to relative path .cub file NewUser1 Microsoft Excel Programming 0 11th Jan 2008 03:59 PM
Want to Set the File Save As path =?Utf-8?B?QnJlbmRh?= Microsoft Excel Programming 1 24th Feb 2006 03:45 AM
Outlook cannot save the URL to a file. Can't find this file. Make sure the path rebs92 Microsoft Outlook 0 13th Dec 2003 11:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:24 AM.