How do I Pass a UNC Filename as Parameter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soule
    New Member
    • Jan 2012
    • 34

    How do I Pass a UNC Filename as Parameter

    Hi, All,

    I recently got smart and decided to go from a drive-specific path to a UNC path in a GetObject statement. Of course, now I have the syntax to contend with which is being digitally belligerent. I think I have two problems...

    1) The full server path I have is \\swba.adpr.acm e.com\data\busi ness-eod. Wouldn't this be too much info. for a UNC pathname? Isn't it simply \\server\folder \file? Do I have three server labels here before I even GET to my folder name? I tried excluding the last two labels and still get same errors (below).

    2) Should I leave brackets in or out? My impression was that in a GetObject statement, brackets were for data outside the db. I've changed it 2+ ways. With brackets, I get the "External Name Not Defined" error. If I leave out the brackets I get the "Expected: expression" error on the first backslash of the double backslash.

    I'm going mental with what was SUPPOSED to make automating code easier. Any ideas?

    Code:
    ' This next procedure opens Outlook by retrieving e-mail template...
    ' The error lines in this & each forthcoming procedure block simply tell the code where to go in event of error.
    
    On Error GoTo PROC_ERR
    
    Dim objOutlookMsg As Object
    
    objOutlookMsg = GetObject([\\swba.adpr.acme.com\data\business-eod\A1 Form Button Automation Email Templates\A1 Outlook Template.oft])
    
    Debug.Print ("Open Outlook by getting template object")
    
    PROC_EXIT:
    Exit Sub
            
    PROC_ERR:
    MsgBox "Error opening Outlook by getting template object." & vbCrLf & Err.Number & Err.Description, vbExclamation + vbOKOnly, "Get Outlook Thru Template"
      
    Resume PROC_EXIT
    Any input will be appreciated. Thank you.

    Frank
  • soule
    New Member
    • Jan 2012
    • 34

    #2
    Solved. Had to drop brockets and add string quotes. Yay.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #3
      Frank, I've changed this title for you as well as your last one. Please check out the threads at the top of the Access forum as they give some very helpful information that will put you in a much better position to ask your questions properly and thus get speedy answers.

      Some general VBA advice :
      1. Declare (dimension) object items precisely where possible. This will help you. Believe me.
      2. Use the F2 Object Browser (See Debugging in VBA) to find what you need.
      3. Use Context-Sensitive Help to determine which parameters are required for a procedure. It would have told you that both parameters for GetObject() are string-type parameters.


      This doesn't mean we're not happy to help, and answer your questions, but you strike me as the type of person who's beyond asking for the basics when you have a simple route to finding them yourself.

      Comment

      • soule
        New Member
        • Jan 2012
        • 34

        #4
        NeoPa,

        Thanks for the links. Sorry if I came across as leeching in my posts today, but I'm under immense pressure on this project, not a natural/voluntary programmer and my memory for new technical details (like syntax) is just average. I'll be getting into the F2 Obj. Browser more. Thanks.

        Frank

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32662

          #5
          Pressure does things to people Frank. Often helping them to forget all they know and panic :-D You'll be fine I'm sure, and we're still happy to help.

          Comment

          Working...