Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Warning Message

Status
Not open for further replies.

jrobin5881

Technical User
Mar 10, 2004
228
US
I'm running VBA code in EXCEL that will follow a hyperlink on a spreadsheet and I'm getting a warning message, "Opening (not the real address because I didn't want to post actual address on internet)
Some files can contain viruses or otherwise be harmful to your computer. It is important to be certain that this file is from a trustworthy source.Would you like to open this file? OK - Cancel."


I tried using Application.DisplayAlerts = False to get around the message and that does not work. Then I turned on the Macro recorder to see how that would handle it and i cut and pasted the code into my test module and that did not work either.

Is there anyway to programitically get around the message? Is it a setting that I have to do in options or is can I use VBA?


Below is My code:
Code:
Sub test()

    Application.DisplayAlerts = False

    ActiveWorkbook.FollowHyperlink Address:=Cells(5, 8), NewWindow:=True

    Application.DisplayAlerts = False

End Sub

And this is the Macro Recorded Code:

Code:
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 3/7/2008 by Authorized User
'    Range("H4").Select
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    Workbooks.Open Filename:="[URL unfurl="true"]http://new/subscriptions/RQ_49480.csv"[/URL]
    ActiveWindow.Visible = False
    Windows("RQ_49480.csv").Visible = True
End Sub
 
Can you use SendKeys to choose the 'OK' button on the warning message?
 
zahead31,

Thanks but that's not working because my code stops when the message appears thereby not allowing the sendkeys to fire.

Here was what I tried to get it to work:

Code:
Sub test()

    Application.DisplayAlerts = False

    ActiveWorkbook.FollowHyperlink Address:=Cells(5, 8), NewWindow:=True
    Application.SendKeys "{TAB}"
    Application.SendKeys "{~}"
    

   End Sub
 
Does this error occur if you type the address into your webbrowser?

Can you change the security of your webrower and/or excel to fix from having the error.

ck1999
 
Hmmmm - that was interesting. The answer is no, I don't get the security message when I type the address in the browser (IE). I get a dialog box asking to save or open the file. Is there a way to use vba to copy and paste the hyperlink from Excel into Internet explorer? Maybe that's the way I should go?

The security setting is set at medium and when I try to set it to low it resets back to medium.I even tried using this code that I found on the MSN Website to no avail.

Code:
Application.AutomationSecurity = msoAutomationSecurityLow
 
Ck,

I performed all the tasks in the article and it did not work.
 
What version of office are you using?

ck1999
 
jrobin

I tested the link (I have excel 07). I updated the registry and retested your code it did NOT work.

So I continued to read the link and saw this

When you open either TIF graphics or Microsoft Document Imaging (MDI) files, you may receive the following warning message, even when you have already implemented the registry key in this article:
Opening path/filename.
Some files can contain viruses or otherwise be harmful to your computer.
It is important to be certain that this file is from a trustworthy source.
Would you like to open this file?
This additional warning message comes from HLINK.dll when link navigation is handled. You can differentiate the Microsoft Office hyperlink warning message from the HLINK warning message by looking for quotation marks around the file path in the warning message. The Office message contains quotation marks, the HLINK message does not. The warning message tries to determine if the file type itself is unsafe by checking the extension, progid, classid, and mime type of the document.

then I ran the code again and noticed the file name did not have quotes so i read further

Method 1: Turn off the "Confirm open after download" option for the file type that you are trying to open
To do this, follow these steps:
1. Double-click My Computer.
2. On the Tools menu, click Folder Options.
3. On the File Types tab, select the appropriate file extension (for example, WMV) in the Registered File Types box, then click the Advanced button.
4. Click to clear the Confirm open after download check box, then click the OK button.
5. Click the Close button on the Folder Options dialog box.

again ran your code and FINALLY it WORKED!!!!!!!!!

Hip Hip Horray

ck1999
 
I should of mentioned under folder Options I changed the option for the csv file which is what you are trying to open.

ck1999
 
Eureka!!!!!
thanks! That worked. Actually I tried it before using the .csv but that didn't so I selected all of the xl type extensions and HOMERUN!!!!

Thanks for hanging in there with me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top