My Assistant
![]() ![]() |
|
|
Oct 19 2010, 10:37 PM
Post
#1
|
|
|
UtterAccess Guru Posts: 753 From: Rendon, Texas |
I am using ConvertReportToPDF from Stephen Lebans for a copy of our purchase orders. All works as expected but I do have one wrinkle I need to try and get around. Not all users have "H" for their server root directory letter. Is there a way that I can determine, dynamically, what the server directory letter is and then use that in place of "H" in the code below?
Thanks in advance, Shane CODE blRet = ConvertReportToPDF("rptPOrders", vbNullString, "H:\Purchase_Orders\" & "PO# " & Me.PONumber & "_" & Me.MarkFor & "_" & Me.VendorsID.Column(1) & ".pdf", False, True, 150, "", "", 0, 0, 0)
|
|
|
|
Oct 19 2010, 10:55 PM
Post
#2
|
|
|
UtterAccess Addict Posts: 199 From: Western Australia |
You need to use the Uniform Naming Convention (UNC) of the drive, ie \\Server\drive\directory.
The attached module will return the UNC of the drive. Cheers Darren
Attached File(s)
|
|
|
|
Oct 19 2010, 11:07 PM
Post
#3
|
|
|
UtterAccess Guru Posts: 753 From: Rendon, Texas |
Thanks Darren but I can not open the attachment that you provided.
Shane This post has been edited by StarsFan: Oct 19 2010, 11:07 PM |
|
|
|
Oct 20 2010, 12:44 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 3,050 From: Perth, Australia |
Try this if you cant open it
CODE Declare Function apiWNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" _ (ByVal strLocalName As String, ByVal strRemoteName As String, _ ByRef rlngRemoteNameLen As Long) As Long Public Function GetUNC(ByVal strPath As String) As String 'Note, this function will only return the UNC for network drives. 'Non-net drives and errors get the original value returned to them On Error GoTo Err_GetUNC Const lngcBuffer As Long = 257 Dim strUNCPath As String Dim strDrive As String If left(strPath, 2) Like "[a-z, A-Z]:" Then strDrive = left(strPath, 2) strUNCPath = strUNCPath & Space(lngcBuffer) 'The function will automatically fill the strUNCPath unless there 'is an error (return<>0), fill strPath if error If apiWNetGetConnection(strDrive, strUNCPath, lngcBuffer) = 0 Then strUNCPath = TrimNull(strUNCPath) & Mid(strPath, 3) Else strUNCPath = strPath End If End If If Len(Trim(strUNCPath)) = 0 Then strUNCPath = strPath GetUNC = strUNCPath Exit_GetUNC: Exit Function Err_GetUNC: MsgBox "Error " & Err.Number & " " & Err.Description Resume Exit_GetUNC End Function Public Function TrimNull(ByVal strNullTermString As String) As String 'This function is used to return a string from a DLL null-terminated string On Error GoTo Err_TrimNull Dim lngNullPos As Long lngNullPos = InStr(strNullTermString, vbNullChar) If lngNullPos > 0 Then TrimNull = left(strNullTermString, lngNullPos - 1) Else TrimNull = strNullTermString End If Exit_TrimNull: Exit Function Err_TrimNull: MsgBox "Error " & Err.Number & " " & Err.Description Resume Exit_TrimNull End Function |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 24th May 2013 - 01:51 PM |