Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2016, 10:11 AM
lostinwebspace lostinwebspace is offline Macro to Open to a Website When No Document Is Open Windows 8 Macro to Open to a Website When No Document Is Open Office 2010 64bit
Novice
Macro to Open to a Website When No Document Is Open
 
Join Date: Apr 2015
Posts: 2
lostinwebspace is on a distinguished road
Default Macro to Open to a Website When No Document Is Open

Hi all,

I'm having a problem. I would like a macro to open a browser window to Google, even when there is no document open. I can do it with a document open using ActiveDocument.FollowHyperlink ("https://www.google.ca/?gws_rd=ssl"). But obviously that's using a property of the ActiveDocument. How do I open this link when there is no ActiveDocument?

Thanks!
Reply With Quote
  #2  
Old 02-13-2016, 10:28 AM
gmaxey gmaxey is offline Macro to Open to a Website When No Document Is Open Windows 7 32bit Macro to Open to a Website When No Document Is Open Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Option Explicit
#If VBA7 Then
  Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, _
                                               ByVal lpOperation As String, ByVal lpFile As String, _
                                               ByVal lpParameters As String, ByVal lpDirectory As String, _
                                               ByVal nShowCmd As Long) As LongPtr
#Else
  Public 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
#End If
Public Sub NewShell(cmdLine As String)
  ShellExecute 1, "open", cmdLine, "", "", 1
lbl_Exit:
  Exit Sub
End Sub
Sub Test()
  NewShell "www.google.com"
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Tags
links, macro, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Open to a Website When No Document Is Open Cannot open DOC email attachment will only save as DOCx which I also cannot open Batty Word 8 08-01-2014 03:24 AM
Macro to Open to a Website When No Document Is Open Formula to open external file with specific program (like open with) pemartins Excel 16 02-24-2014 11:39 PM
Macro to Open to a Website When No Document Is Open Run-time error '1004': Document not saved. The document may be open... doctor_who12 Excel Programming 1 01-22-2014 04:47 PM
macro to open another document coconutt Word VBA 1 06-11-2012 04:39 AM
Word 2003 .doc: open website .doc link inside of browser window SunnyOz Word 0 08-16-2010 01:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft