PC Review


Reply
Thread Tools Rate Thread

HOW TO CHANGE RESULT WITH SAME MACRO CODE

 
 
K
Guest
Posts: n/a
 
      17th Jun 2008
Hi all, I got macro in which I have code (see below)
Range("A1").Value = ThisWorkbook.FullName
Above macro code brings "F:\Kas\Documents\Profit.xlsx" text in cell
"A1"
Is there way that by putting "ThisWorkbook.FullName" just bring "\Kas
\Documents\Profit.xlsx" and exclud the word "F:" and add "\\Home\ABC"
in the line
so it should be coming in cell "A1" "\\Home\ABC\Kas\Documents
\Profit.xlsx". I hope I was able to explain my question. Please can
any friend help?
 
Reply With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      17th Jun 2008
Here is an API to retrun the UNC name from a drive letter. I assume this is
what you are looking for?

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("G")
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


"K" wrote:

> Hi all, I got macro in which I have code (see below)
> Range("A1").Value = ThisWorkbook.FullName
> Above macro code brings "F:\Kas\Documents\Profit.xlsx" text in cell
> "A1"
> Is there way that by putting "ThisWorkbook.FullName" just bring "\Kas
> \Documents\Profit.xlsx" and exclud the word "F:" and add "\\Home\ABC"
> in the line
> so it should be coming in cell "A1" "\\Home\ABC\Kas\Documents
> \Profit.xlsx". I hope I was able to explain my question. Please can
> any friend help?
>

 
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
Macro code to partially format font colour of result in cellcontaining a formula Mike Magill Microsoft Excel Discussion 3 19th Apr 2010 08:34 PM
Changing FormField result in Macro does not change link colem Microsoft Word Document Management 1 8th Jan 2008 11:54 AM
Can I use code/macro to change code/macro in an existing file? =?Utf-8?B?U2NvdHQgQmVkb3dz?= Microsoft Excel Programming 2 14th Feb 2007 05:50 AM
Executing code in a library as a result of a worksheet change Ian Wheaton Microsoft Excel Programming 1 24th Nov 2006 04:03 PM
Change result of Macro Recorder Jim May Microsoft Excel Misc 3 21st May 2005 01:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:53 AM.