Manufacturing Information Solutions Forum Index Manufacturing Information Solutions
Your Place for Support and Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Code to convert UNC to URL

 
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access
View previous topic :: View next topic  
Author Message
dawn
Master Poster


Joined: 26 Jun 2004
Posts: 311
Location: Mishawaka, IN

PostPosted: Fri Dec 05, 2008 11:08 am    Post subject: Code to convert UNC to URL Reply with quote

Q: I've got a number of users who publish data to the intranet by copying it
onto a server then making links to it.

I'd like to make a script for the people who are finding it a little
confusing to convert the UNC of the file into a URL.

Here's an example:
UNC: \\web1a\PIBReports\BCA\Admin_Reports\User_List.pdf
URL: http://web1/pibreports/bca/admin_reports/user_list.pdf

A:

Code:
-------------------------------------------------------------
on error resume next

Function GetUrlFromUnc(Unc)
Const BASE_URL = "http://web1/"
Const BASE_FOLDER = "pibreports"
Dim iPos
iPos = InStr(1, Unc, BASE_FOLDER, vbTextCompare)
If iPos > 0 Then
Dim sSubPath
sSubPath = Mid(Unc, iPos)
sSubPath = Replace(sSubPath, "\", "/")
sSubPath = Escape(sSubPath)
GetUrlFromUnc = lcase(BASE_URL & sSubPath)
Else
'Invalid Folder
GetUrlFromUnc = ""
End If
End Function

AppCap = "Convert File Path to HyperLink"
strCopy = GetUrlFromUnc(InputBox("Please enter the file
path",AppCap,"\\web1a\PIBReports\"))

If strCopy <> "" Then
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
objIE.document.parentwindow.clipboardData.SetData "text", strCopy
objIE.Quit
MsgBox "The HyperLink (URL) to your file has been copied to the clipboard,
please use the Paste command on the Edit menu or 'CTRL+V' to use it." +
Chr(10) + strCopy, 64, AppCap
Else
End If
'-------------------------------------------------------------

_________________
Dawn Mitchell
Manufacturing Information Solutions
www.mis-group.com
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group