Solved

Outlook 2010 opening network url via vba

Posted on 2014-09-23
10
803 Views
Last Modified: 2014-09-26
In Outlook 2010 I have code that needs to open a link.
Sub LinkFollow()

x = Shell("C:\Windows\explorer.exe  \\ntwkdata1\vol1\oft.url", vbMaximizedFocus)

End Sub

Open in new window

When I run the code, I get the window in the attached jpg.  How can I make that just automatically select Open?
What displays after code is run
0
Comment
Question by:pmpatane
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 40340882
You can't Internet Explorer security will stop you.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40341178
Hi, pmpatane.

Please try this approach.  It works when the .url file is on a local drive.  I'm not in a position at the moment to test it on a network drive.

Private Declare Function ShellExecute Lib "shell32.dll" _
  Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
  ByVal lpFile As String, ByVal lpParameters As String, _
  ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute 0&, "open", "\\ntwkdata1\vol1\oft.url", 0&, 0&, 0&

Open in new window

0
 

Author Comment

by:pmpatane
ID: 40342096
Hi BlueDevilFan,
It appears David Johnston is correct, that it will be blocked.  The code you gave me produces the same result, that lovely dialog box.  Alas, my users will need to click the open button.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 76

Expert Comment

by:David Lee
ID: 40342377
I've just tested this on my system and it worked perfectly opening a .url shortcut.  I tired it with IE and Firefox and both worked.  I don't know what you have your shortcut pointing to, I pointed mine to google.com, so perhaps that's the difference.
0
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 40343003
a hyperlink to a web address will never give you an open or save dialog it will always open. BlueDevilFan what made you think any differntly.  You are comparing apples to oranges as we are referring to a different mime type. a file that the browser doesn't know how to handle i.e. a word document then you are given the option to open or save the file. the file gets saved to disk in both cases but in different locations. with open the file exists in the browsers temporary folder and in the save option it is saved where the user wants it to be saved.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40343093
David - Good points.

pmpatane - What is you ultimate goal here?  If we knew that, then we might be able to suggest an alternative.
0
 

Author Comment

by:pmpatane
ID: 40344193
We have a macro running in Outlook, and at times it needs to open a template (.oft)  The template is stored in a location that most of our users do not have mapped, so the macro points to a shortcut on a shared drive.  But I just tested the code again putting in the exact internal URL and still I get that dialog box
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 40344345
There's an easier way to do this.  Add this code to that you already have.  To create an item from a template, call the subroutine and pass it the path to the template file.  That will be the same path as the target in the shortcut.

Sub CreateItemFromTemplate(strTemplate As String)
    Dim olkItm As Outlook.MailItem
    Set olkItm = Application.CreateItemFromTemplate(strTemplate)
    olkItm.Display
    Set olkItm = Nothing
End Sub

Open in new window

0
 

Author Closing Comment

by:pmpatane
ID: 40346904
That worked perfectly...THANKS!!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40347227
You're welcome!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 365 Install Issues 3 62
Outlook 2016 10 44
Stop excel from formatting numbers 4 21
Display Excel gridlines when called from Access 7 18
In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question