Click here to Skip to main content
Licence 
First Posted 18 Mar 2003
Views 36,437
Bookmarked 11 times

Visual Studio Headlines

By | 18 Mar 2003 | Article
A macro to show news headlines in Visual C++.

Introduction

There are many programs to display headlines from websites but who needs another app burning up resources! You can read the headlines from Visual Studio with this handy macro. The fact that it looks like code helps too - easier to hide than a web browser at work. I joke.

Install the Macro

Copy the vsrdf.dsm file to C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Macros.

Run Visual Studio and go to the Tools menu and select Customize. In the dialog shown, select the 'Add ins and Macros' tab. Click Browse to select the vsrdf.dsm file. The macro file can be edited using the 'Macro' entry in the Tools menu. See MSDN for more info on VS macros.

Modify the Macro

Modify the websites as appropriate in the first sub. Assign the macro to a button and that's it. The tag removal code was found on Code Project. Have fun.

'--------------------------------------------------------------------
'FILE DESCRIPTION: Web Reader by Davy Mitchell www.latedecember.com
'--------------------------------------------------------------------

Sub GetHeadlines()
'DESCRIPTION: Grabs headlines and displays them as text.


    Documents.Add "Text"

    RDFText = GetHTML("http://christdot.org/backend.php")
    ActiveDocument.Selection = ActiveDocument.Selection & stripHTML(RDFText)

    RDFText = GetHTML("http://slashdot.org/slashdot.rdf")
    ActiveDocument.Selection = ActiveDocument.Selection & stripHTML(RDFText)

    'Store
    ActiveDocument.Save("C:\news.cpp")

End Sub

Function GetHTML(strPage)
       On Error Resume Next
       Set objXMLHttp = CreateObject("Microsoft.XMLHTTP")
       objXMLHttp.Open "GET", strPage, False, "", ""

       objXMLHttp.Send
       If Err.Number = 0 Then
              If objXMLHttp.Status = 200 Then
                     GetHTML = objXMLHttp.ResponseText
              Else
                     GetHTML = "Incorrect URL"
              End If
       Else
              GetHTML = Err.Description
       End If
       Set objXMLHttp = Nothing
End Function

function stripHTML(strInput)
    
    strInput = Replace(strInput, "<title>",vbCR + vbLF +"<title>")
    strInput = Replace(strInput, "</title>",vbCR + vbLF +"</title>")
    strInput = Replace(strInput, "<description>",vbCR + vbLF +"<description>")
    strInput = Replace(strInput, "</description>",vbCR + vbLF +"</description>")
    strInput = Replace(strInput, "<link>","<link>//")
    dim regEx
    set regEx = new RegExp
    regEx.Pattern = "<([^>]|\n)*>"
    regEx.IgnoreCase = true
    regEx.Global = true

    StripHTML = regEx.Replace(strInput, "")
    
end function

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Davy Mitchell

Web Developer

United Kingdom United Kingdom

Member

After being created, I spent too much of my childhood with a Dragon 32. Since then I have worked on Personality software, Children's websites, ATM and transport software. Most hobby development is web based and I often have a iPaq in my hand.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThis doesn't work PinmemberMortman9:47 19 Mar '03  
GeneralRe: This does work PinmemberDavy Mitchell9:53 19 Mar '03  
GeneralRe: This does work PinmemberKant12:22 19 Mar '03  
GeneralRe: This does work PinmemberDavy Mitchell20:30 19 Mar '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 19 Mar 2003
Article Copyright 2003 by Davy Mitchell
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid