Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default is this an accepted way to set the path

i set a variable to the path the files are in at my location. when i take it
to the client, i have to remember to change the string to their path. so i
used the environ("username") to set it. is this a normal way to do this so
you don't always have to remember to change it?


If UCase(Environ("UserName")) = "USER" Then ' this is me at my location
fPath = "N:\My Documents\FolderName\"
Else
fPath = "\\ServerName\share\FolderName\"
End If

--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default is this an accepted way to set the path

There is an API call called GetComputerName which returns the name of
the computer but I don't know if you can call API's with VBA I'm
interested in finding out though....

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default is this an accepted way to set the path

don't think that will help me. i am the only one that logs in here, so all i
have to do is check for my login name. if it's not me, then it must be my
client. i can't check for every computer name they use. i have 4 computers
here, and i always log in as me on every one.

so computernames don't do me any good.

--


Gary


wrote in message
ups.com...
There is an API call called GetComputerName which returns the name of
the computer but I don't know if you can call API's with VBA I'm
interested in finding out though....



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default is this an accepted way to set the path

You don't need the API

MsgBox Environ("ComputerName")

That bieng said yes you can access the API's
--
HTH...

Jim Thomlinson


" wrote:

There is an API call called GetComputerName which returns the name of
the computer but I don't know if you can call API's with VBA I'm
interested in finding out though....


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default is this an accepted way to set the path

That seems acceptable. You could also see what the UNC is for the local N
drive with this function which may or may not help...

Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA"
( _
ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, _
ByRef cbRemoteName As Long) As Long

Sub Test()
MsgBox UNCfromLocalDriveName("N")
End Sub

Function UNCfromLocalDriveName(strLocalDrive) As String
'Find UNC from Local path
'i.e. Local drive "F:" = "\\RdaServer3\sys1"
' example of usage: UNCfromLocalDriveName("P") <-Actual Drive Letter
' or UNCfromLocalDriveName(A2) <-Cell reference
'
Dim sLocal As String
Dim sRemote As String * 255
Dim lLen As Long

Application.Volatile

sRemote = String$(255, Chr$(32))

lLen = 255
sLocal = strLocalDrive & ":"

WNetGetConnection sLocal, sRemote, lLen

UNCfromLocalDriveName = Trim(sRemote)

End Function

--
HTH...

Jim Thomlinson


"Gary Keramidas" wrote:

i set a variable to the path the files are in at my location. when i take it
to the client, i have to remember to change the string to their path. so i
used the environ("username") to set it. is this a normal way to do this so
you don't always have to remember to change it?


If UCase(Environ("UserName")) = "USER" Then ' this is me at my location
fPath = "N:\My Documents\FolderName\"
Else
fPath = "\\ServerName\share\FolderName\"
End If

--


Gary






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
From Accepted Bid to Purchase Order Stormingerman Excel Discussion (Misc queries) 0 April 26th 08 07:28 PM
No. of digits accepted in one cell Rayaprolu Excel Worksheet Functions 3 May 17th 06 07:38 PM
using a selection box and moving the accepted data madsenfence Excel Worksheet Functions 1 January 19th 06 03:42 AM
Inconsistency in how Range object is accepted? Chris B Excel Programming 2 August 16th 05 05:32 PM
line not accepted ? Sunil Patel Excel Programming 2 July 8th 05 01:04 AM


All times are GMT +1. The time now is 08:01 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"