Guest User

Untitled

a guest
Jan 12th, 2013
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub CommandButton1_Click()
  2. Dim shortcutfile As String
  3. Dim myadddate As Double
  4.    
  5.     Application.ScreenUpdating = False
  6.     myfullfilename = Application.GetSaveAsFilename(InitialFileName:="Bookmarks.html", fileFilter:="HTML Files, *.html")
  7.  
  8.     If myfullfilename = False Then Exit Sub
  9.     mypath = Left$(myfullfilename, InStrRev(myfullfilename, "\")) & "InternetShortCuts"
  10.     Workbooks.OpenText FileName:=myfullfilename, Origin:=-535, DataType:=xlDelimited, Tab:=False, semicolon:=False, comma:=False, Space:=False
  11.    
  12.     On Error Resume Next
  13.     MkDir mypath
  14.     On Error GoTo 0
  15.    
  16.     Set mysheet = ActiveWorkbook.Sheets(1)
  17.     With mysheet
  18.     For i = 1 To .UsedRange.SpecialCells(xlCellTypeLastCell).Row
  19.        
  20.         If InStr(.Cells(i, 1), "HREF=") <> 0 Then
  21.             urlstart = InStr(.Cells(i, 1), "HREF=")
  22.             urlend = InStr(.Cells(i, 1), "ADD_DATE=")
  23.             myurl = Mid(.Cells(i, 1), urlstart + 6, urlend - urlstart - 8)
  24.                  
  25.             adddateend = InStr(.Cells(i, 1), "LAST_MODIFIED=")
  26.             myadddate = Mid(.Cells(i, 1), urlend + 10, adddateend - urlend - 12)
  27.             myadddate = DateAdd("s", myadddate, DateSerial(1970, 1, 1))
  28.            
  29.             titleend = InStrRev(.Cells(i, 1), "<")
  30.             titlestart = InStrRev(.Cells(i, 1), ">", titleend)
  31.             mytitle = Mid(.Cells(i, 1), titlestart + 1, titleend - titlestart - 1)
  32.             mytitle = Left(mytitle, 100)
  33.            
  34.             forbidden = Array("\", "/", ":", "*", "?", """", "<", ">", "|", "&quot;")
  35.             For j = 0 To UBound(forbidden)
  36.                 mytitle = Replace(mytitle, forbidden(j), "")
  37.             Next j
  38.            
  39.             shortcutfile = mypath & "\" & Trim(mytitle) & ".url"
  40.             With CreateObject("Scripting.FileSystemObject")
  41.               With .CreateTextFile(shortcutfile, , True)
  42.                 .write "[InternetShortcut]" & vbNewLine
  43.                 .write "URL=" & myurl
  44.                 .Close
  45.               End With
  46.             End With
  47.            
  48.            
  49.             Call Settimestamp(shortcutfile, myadddate)
  50.            
  51.         End If
  52.     Next i
  53.     Close
  54.     .Parent.Close False
  55.     End With
  56.    
  57.     Application.ScreenUpdating = True
  58. End Sub
Advertisement
Add Comment
Please, Sign In to add comment