Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default code is not working.

Hi All,

This code checks the file path of workbook as it should be always on shared
drive.

Function PathAndName() As Boolean

Dim WBPath As String

WBPath = ThisWorkbook.Sheets("Data").Range("B3").Value
'the string length is more the 100 carectors in length.

If ThisWorkbook.Path < WBPath Then

MsgBox "This workbook is not correct path."
Exit Function

End If

End Function

This small funtion is troubling me a lot. It works on some machines and it
doesnt work on some. Some times it works on my machine and some times i
doesnt.

Kindly help
Heera Chavan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default code is not working.

The function doesn't return a value and if on a worksheet will not run since
no parameter is pass to the function. worksheet functions only get called
when a dependency is updated. The dependency is the passed parameter which
doesn't exist.

Function PathAndName() As Boolean

Dim WBPath As String

WBPath = ThisWorkbook.Sheets("Data").Range("B3").Value
'the string length is more the 100 carectors in length.

If ThisWorkbook.Path < WBPath Then

MsgBox "This workbook is not correct path."
PathAndName = False
else
PathAndName = True
End If

End Function


I would change the code to pass B3

=PathAndName(Data!B3)

Function PathAndName(WBPath as string) As Boolean

'the string length is more the 100 carectors in length.

If ThisWorkbook.Path < WBPath Then

MsgBox "This workbook is not correct path."
PathAndName = False
else
PathAndName = True
End If

End Function



"Heera Chavan" wrote:

Hi All,

This code checks the file path of workbook as it should be always on shared
drive.

Function PathAndName() As Boolean

Dim WBPath As String

WBPath = ThisWorkbook.Sheets("Data").Range("B3").Value
'the string length is more the 100 carectors in length.

If ThisWorkbook.Path < WBPath Then

MsgBox "This workbook is not correct path."
Exit Function

End If

End Function

This small funtion is troubling me a lot. It works on some machines and it
doesnt work on some. Some times it works on my machine and some times i
doesnt.

Kindly help
Heera Chavan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code is not working.


Apart from Joel's observations, I suspect that the "works on some
machines and it doesnt work on some" come from the shared drive
location. Perhaps some machines have a different drive letter for the
drive or have the folder mapped differently.

I did a google for 'unc path excel vba' and the very first entry proved
the most useful:
'dailydoseofexcel'
(http://www.dailydoseofexcel.com/arch...6/21/unc-path/)

Specifically this:
application.CommandBars("Web").Controls("Address:" ).text

Now all you need to do is replace B3 with the UNC path of the file.

As an aside, there was also a possibly useful tip (I've not explored
it) at
'spyjournal.biz'
(http://www.spyjournal.biz/techtips/2...s-in-urls.html)

p45cal

Heera Chavan;553727 Wrote:
Hi All,

This code checks the file path of workbook as it should be always on
shared
drive.

Function PathAndName() As Boolean

Dim WBPath As String

WBPath = ThisWorkbook.Sheets("Data").Range("B3").Value
'the string length is more the 100 carectors in length.

If ThisWorkbook.Path < WBPath Then

MsgBox "This workbook is not correct path."
Exit Function

End If

End Function

This small funtion is troubling me a lot. It works on some machines and
it
doesnt work on some. Some times it works on my machine and some times
i
doesnt.

Kindly help
Heera Chavan



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=152645

Microsoft Office Help

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default code is not working.

Hi Joel,

Thanks for your reply.
Its not a worksheet function.
My problem is in the following code If ThisWorkbook.Path < WBPath Then.
the above mentioned code is not working sometimes.

Regards
Heera Chavan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default code is not working.

I've posted a resonse to this half an hour ago here
http://www.thecodecage.com/forumz/ex...t-working.html
but it's not coming through to this site
--
p45cal


"Heera Chavan" wrote:

Hi Joel,

Thanks for your reply.
Its not a worksheet function.
My problem is in the following code If ThisWorkbook.Path < WBPath Then.
the above mentioned code is not working sometimes.

Regards
Heera Chavan



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default code is not working.

Hi P45cal,

Thank you....your answer was quite near....but I understood cause after
going trough the post.

appriciate your work.....

"p45cal" wrote:

I've posted a resonse to this half an hour ago here
http://www.thecodecage.com/forumz/ex...t-working.html
but it's not coming through to this site
--
p45cal


"Heera Chavan" wrote:

Hi Joel,

Thanks for your reply.
Its not a worksheet function.
My problem is in the following code If ThisWorkbook.Path < WBPath Then.
the above mentioned code is not working sometimes.

Regards
Heera Chavan

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
Help - Code not always working twperplex Excel Programming 1 August 4th 06 06:24 PM
Code not working Jim May Excel Programming 5 September 13th 05 04:39 PM
Code not working Todd Huttenstine Excel Programming 1 June 10th 04 05:06 PM
Code not Working - Help please Brian Excel Programming 2 November 18th 03 10:58 PM
why this code not working Bernie Deitrick[_2_] Excel Programming 0 September 2nd 03 05:08 PM


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

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

About Us

"It's about Microsoft Excel"