Results 1 to 10 of 10

Thread: text files

  1. #1
    jodiey
    Guest

    text files

    I'd like to open a .txt file for input. I'm using the VB Editor in WordPerfect 9. But instead of saying Open "D:filename", I'd like to use the network drive name, which is 'D on Renrtp'(L. I've tried writing this a few different ways but I'm am getting bad filename errors. Does someone know how I would write this? Thanks a lot.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: text files

    Hi,
    Your network drive appears to be mapped to L: so L:filename should work.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: text files

    Try an UNC type name eg "RenrtpDatafilename.wpd"
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    jodiey
    Guest

    Re: text files

    using the Open Lathfilename works fine on my computer, but everyone who will be using this this program is mapped to a different drive, that's why I would like to use the 'D on Renrtp'.

  5. #5
    jodiey
    Guest

    Re: text files

    I'm sorry, I'm not very familiar with VBA, but I tried both Open "Renrtppathfile.txt" and Open "D on Renrtppathfile.txt" and both gave me a bad filename error.

  6. #6
    jodiey
    Guest

    Re: text files

    Ok, I used this statement:
    Open "D on 'Renrtp_mapweb1'Program FilesMapInfoMapXtremeJodieJodie1.txt" For Input As #1
    and I now get a Path/File Access error.

  7. #7
    Star Lounger
    Join Date
    Jan 2001
    Location
    L.A., California
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text files

    Here's a function that can convert a drive letter to a UNC path name.

    Declare the following Windows API function at the top of a module (all on one line, in case it wraps here):

    Public Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocationName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

    Put the following function inside the module (Ignore the apostrophes, they're just there to preserve the indents):

    Public Function GetUNC(ByVal DriveLetter As String) As String
    On Error Resume Next

    Dim sReturnVal As String
    Dim lSize As Long
    Dim lResult As Long

    GetUNC = ""
    sReturnVal = Space$(255)
    lSize = Len(sReturnVal)

    DriveLetter = DriveLetter & ":"
    DriveLetter = Left$(DriveLetter, InStr(1, DriveLetter, ":"))

    lResult = WNetGetConnection(DriveLetter, sReturnVal, lSize)
    If lResult = 0 Then
    lSize = InStr(1, sReturnVal, Chr$(0))
    GetUNC = Left$(sReturnVal, lSize - 1)
    End If

    End Function

    If you execute a line of code such as:

    UNCDrive = GetUNC("L")

    UNCDrive should then contain:

    RenrtpD

    Hope this helps,

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: text files

    The way I interpret "D on Renrtp" is:

    renrtpd

  9. #9
    jodiey
    Guest

    Re: text files

    Wow, that worked! Thank you sooo much!!!

  10. #10
    kelliel
    Guest

    Re: text files

    Great little function there, RMittleman.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •