By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,488 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,488 IT Pros & Developers. It's quick & easy.

How do I Pass a UNC Filename as Parameter

P: 34
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.acme.com\data\business-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?

Expand|Select|Wrap|Line Numbers
  1. ' This next procedure opens Outlook by retrieving e-mail template...
  2. ' The error lines in this & each forthcoming procedure block simply tell the code where to go in event of error.
  3.  
  4. On Error GoTo PROC_ERR
  5.  
  6. Dim objOutlookMsg As Object
  7.  
  8. objOutlookMsg = GetObject([\\swba.adpr.acme.com\data\business-eod\A1 Form Button Automation Email Templates\A1 Outlook Template.oft])
  9.  
  10. Debug.Print ("Open Outlook by getting template object")
  11.  
  12. PROC_EXIT:
  13. Exit Sub
  14.  
  15. PROC_ERR:
  16. MsgBox "Error opening Outlook by getting template object." & vbCrLf & Err.Number & Err.Description, vbExclamation + vbOKOnly, "Get Outlook Thru Template"
  17.  
  18. Resume PROC_EXIT
  19.  
Any input will be appreciated. Thank you.

Frank
Jan 17 '12 #1
Share this Question
Share on Google+
4 Replies


P: 34
Solved. Had to drop brockets and add string quotes. Yay.
Jan 17 '12 #2

NeoPa
Expert Mod 15k+
P: 31,709
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.
Jan 17 '12 #3

P: 34
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
Jan 18 '12 #4

NeoPa
Expert Mod 15k+
P: 31,709
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.
Jan 18 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.