Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default saveas calling a variable

HI,
I need to use an inputbox to get the user name of the user
and then save the workbook to a specific location. This
location where I need to reinsert the user name as a
variable. I try this but something is wrong with the
argument. I haven't succeed to writte the synthaxe to
insert my variable in the location.
Thanks for your advices
Application.ThisWorkbook.SaveAs D:\The Documents and
Settings/<user name/Application Data/Microsoft/AddIns


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default saveas calling a variable

Douvid,
try

ThisWorkbook.SaveAs "D:\The Documents and Settings/" & <user name &
"/Application Data/Microsoft/AddIns"

watch for wrap-around.


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
HI,
I need to use an inputbox to get the user name of the user
and then save the workbook to a specific location. This
location where I need to reinsert the user name as a
variable. I try this but something is wrong with the
argument. I haven't succeed to writte the synthaxe to
insert my variable in the location.
Thanks for your advices
Application.ThisWorkbook.SaveAs D:\The Documents and
Settings/<user name/Application Data/Microsoft/AddIns




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default saveas calling a variable

ok bob and how do I have to declare the variable that
will insert the user name ? this causes me problems

-----Original Message-----
Douvid,
try

ThisWorkbook.SaveAs "D:\The Documents and Settings/"

& <user name &
"/Application Data/Microsoft/AddIns"

watch for wrap-around.


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
HI,
I need to use an inputbox to get the user name of the

user
and then save the workbook to a specific location. This
location where I need to reinsert the user name as a
variable. I try this but something is wrong with the
argument. I haven't succeed to writte the synthaxe to
insert my variable in the location.
Thanks for your advices
Application.ThisWorkbook.SaveAs D:\The Documents and
Settings/<user name/Application Data/Microsoft/AddIns




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default saveas calling a variable

sUsername=Inputbox("Please supply your user name")

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
ok bob and how do I have to declare the variable that
will insert the user name ? this causes me problems

-----Original Message-----
Douvid,
try

ThisWorkbook.SaveAs "D:\The Documents and Settings/"

& <user name &
"/Application Data/Microsoft/AddIns"

watch for wrap-around.


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
HI,
I need to use an inputbox to get the user name of the

user
and then save the workbook to a specific location. This
location where I need to reinsert the user name as a
variable. I try this but something is wrong with the
argument. I haven't succeed to writte the synthaxe to
insert my variable in the location.
Thanks for your advices
Application.ThisWorkbook.SaveAs D:\The Documents and
Settings/<user name/Application Data/Microsoft/AddIns




.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default saveas calling a variable

Hi Bob,
this is the procedure I'm using but I always get error
message or about the oject or about something else, can
you help on that one. thanks a lot
douvid

Sub installmytooloading()
Dim qst
Dim user

user = InputBox("Please enter your username for this
computer", "UserName")
ThisWorkbook.SaveAs "D:\The Documents and Settings/" &
user.Value & "/Application Data/Microsoft/AddIns"

End Sub

-----Original Message-----
sUsername=Inputbox("Please supply your user name")

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
ok bob and how do I have to declare the variable that
will insert the user name ? this causes me problems

-----Original Message-----
Douvid,
try

ThisWorkbook.SaveAs "D:\The Documents and

Settings/"
& <user name &
"/Application Data/Microsoft/AddIns"

watch for wrap-around.


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the

Purbecks


"Douvid" wrote in message
...
HI,
I need to use an inputbox to get the user name of the

user
and then save the workbook to a specific location.

This
location where I need to reinsert the user name as a
variable. I try this but something is wrong with the
argument. I haven't succeed to writte the synthaxe to
insert my variable in the location.
Thanks for your advices
Application.ThisWorkbook.SaveAs D:\The Documents and
Settings/<user name/Application

Data/Microsoft/AddIns




.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default saveas calling a variable

Douvid,

You do not use user.Value, as user is a variable not an object with a Value
property. Just use

user = InputBox("Please enter your username for this computer", "UserName")
ThisWorkbook.SaveAs "D:\The Documents and Settings/" & user & _
"/Application Data/Microsoft/AddIns"

You can also get the user automatically (I am assuming you have XP, or
Win2000?). This function returns it
Public Declare Function GetUserName Lib "advapi32.dll" _

Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function

So you would then use
ThisWorkbook.SaveAs "D:\The Documents and Settings/" & Username & _
"/Application Data/Microsoft/AddIns"

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
Hi Bob,
this is the procedure I'm using but I always get error
message or about the oject or about something else, can
you help on that one. thanks a lot
douvid

Sub installmytooloading()
Dim qst
Dim user

user = InputBox("Please enter your username for this
computer", "UserName")
ThisWorkbook.SaveAs "D:\The Documents and Settings/" &
user.Value & "/Application Data/Microsoft/AddIns"

End Sub

-----Original Message-----
sUsername=Inputbox("Please supply your user name")

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
ok bob and how do I have to declare the variable that
will insert the user name ? this causes me problems

-----Original Message-----
Douvid,
try

ThisWorkbook.SaveAs "D:\The Documents and

Settings/"
& <user name &
"/Application Data/Microsoft/AddIns"

watch for wrap-around.


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the

Purbecks


"Douvid" wrote in message
...
HI,
I need to use an inputbox to get the user name of the
user
and then save the workbook to a specific location.

This
location where I need to reinsert the user name as a
variable. I try this but something is wrong with the
argument. I haven't succeed to writte the synthaxe to
insert my variable in the location.
Thanks for your advices
Application.ThisWorkbook.SaveAs D:\The Documents and
Settings/<user name/Application

Data/Microsoft/AddIns




.



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default saveas calling a variable

thanks a lot, this was just what I needed.
great job

-----Original Message-----
Douvid,

You do not use user.Value, as user is a variable not an

object with a Value
property. Just use

user = InputBox("Please enter your username for this

computer", "UserName")
ThisWorkbook.SaveAs "D:\The Documents and Settings/" &

user & _
"/Application Data/Microsoft/AddIns"

You can also get the user automatically (I am assuming

you have XP, or
Win2000?). This function returns it
Public Declare Function GetUserName Lib "advapi32.dll" _

Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function

So you would then use
ThisWorkbook.SaveAs "D:\The Documents and Settings/" &

Username & _
"/Application Data/Microsoft/AddIns"

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Douvid" wrote in message
...
Hi Bob,
this is the procedure I'm using but I always get error
message or about the oject or about something else, can
you help on that one. thanks a lot
douvid

Sub installmytooloading()
Dim qst
Dim user

user = InputBox("Please enter your username for this
computer", "UserName")
ThisWorkbook.SaveAs "D:\The Documents and Settings/" &
user.Value & "/Application Data/Microsoft/AddIns"

End Sub

-----Original Message-----
sUsername=Inputbox("Please supply your user name")

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the

Purbecks


"Douvid" wrote in message
...
ok bob and how do I have to declare the variable that
will insert the user name ? this causes me problems

-----Original Message-----
Douvid,
try

ThisWorkbook.SaveAs "D:\The Documents and

Settings/"
& <user name &
"/Application Data/Microsoft/AddIns"

watch for wrap-around.


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the

Purbecks


"Douvid" wrote in message
...
HI,
I need to use an inputbox to get the user name of

the
user
and then save the workbook to a specific location.

This
location where I need to reinsert the user name

as a
variable. I try this but something is wrong with

the
argument. I haven't succeed to writte the

synthaxe to
insert my variable in the location.
Thanks for your advices
Application.ThisWorkbook.SaveAs D:\The Documents

and
Settings/<user name/Application

Data/Microsoft/AddIns




.



.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling name of Sheet as a Variable? thekeytothedoor Excel Worksheet Functions 1 January 1st 10 08:48 AM
calling a value from another file using a variable in the file nam DA_Potts[_2_] Excel Worksheet Functions 3 December 3rd 07 12:25 AM
Calling a Userform from a Predefined Variable [email protected] Excel Worksheet Functions 0 April 21st 07 03:44 PM
Calling a procudure through variable name Basu Excel Discussion (Misc queries) 2 August 30th 06 08:55 AM
calling variable within string [email protected] Excel Worksheet Functions 8 May 4th 06 03:07 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"