Advertisement
Guest User

Untitled

a guest
Jul 12th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1. Revision Summary Date Revision History Revision Class Comments
  2. 06/30/2008 0.9 Major First release. Additional indexing and cross referencing as well as minor editorial and technical edits anticipated prior to 1.0 release.
  3. 06/30/2009 0.95 Major Updated to include preliminary information on the VBA language from the pre-release version of VBA 7.
  4. 03/15/2010 1.0 Major Updated to include information on the VBA language as of VBA 7.
  5. 03/15/2012 1.01 Major Updated to include information on the VBA language as of VBA 7.1, as shipped in the Office 15 Technical Preview.
  6. 04/30/2014 1.02 Editorial Revised and edited technical content.
  7.  
  8. Set Dict = CreateObject("Scripting.Dictionary")
  9. On Error Resume Next
  10. Dict.Add "Key1", "Data"
  11. Dict.Add "Key2", "Data"
  12. Dict.Add "Key3", "Data"
  13. If Err.Number <> 0 then
  14. If LCase(Arg(1)) = "l" then
  15. Dict.Remove Line
  16. Dict.Add Line, ""
  17. End If
  18. End If
  19. For Each thing in Dict.Keys()
  20. Msgbox thing
  21. Next
  22.  
  23. Set rs = CreateObject("ADODB.Recordset")
  24. With rs
  25. .Fields.Append "SortKey", 4
  26. .Fields.Append "Txt", 201, 5000
  27. .Open
  28. .AddNew
  29. .Fields("SortKey").value = 1
  30. .Fields("Txt").value = "Line1"
  31. .UpDate
  32. .AddNew
  33. .Fields("SortKey").value = 2
  34. .Fields("Txt").value = "Line2"
  35. .UpDate
  36. .AddNew
  37. .Fields("SortKey").value = 3
  38. .Fields("Txt").value = "Line3"
  39. .UpDate
  40.  
  41. 'Sorting
  42. .Sort = "SortKey ASC"
  43.  
  44. 'Filtering
  45. .filter = "Sortkey < 3"
  46.  
  47. 'Writing it out
  48. Do While not .EOF
  49. MsgBox .Fields("Txt").Value
  50. .MoveNext
  51. Loop
  52.  
  53. Set emailObj = CreateObject("CDO.Message")
  54. emailObj.From = "dcandy@gmail.com"
  55. emailObj.To = "dcandy@gmail.com"
  56. emailObj.Subject = "Test CDO"
  57. emailObj.TextBody = "Test CDO"
  58. emailObj.AddAttachment "C:/Users/David Candy/Desktop/err.fff"
  59. Set emailConfig = emailObj.Configuration
  60. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
  61. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
  62. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  63. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  64. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
  65. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "dc"
  66. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "S1"
  67. emailConfig.Fields.Update
  68. emailObj.Send
  69. If err.number = 0 then
  70. Msgbox "Done"
  71. Else
  72. Msgbox err.number & " " & err.description
  73. err.clear
  74. End If
  75.  
  76. Set fso = CreateObject("Scripting.FileSystemObject")
  77. Set Outp = Wscript.Stdout
  78. Set wshShell = CreateObject("Wscript.Shell")
  79. Set ShApp = CreateObject("Shell.Application")
  80. On Error Resume Next
  81. ' Have to use MSXML2 as Microsoft.XMLHTTP caused Access Denied errors after the page had been repeatedly gotten, go figure that one
  82. Set File = WScript.CreateObject("MSXML2.ServerXMLHTTP.4.0")
  83. Set File = WScript.CreateObject("Microsoft.XMLHTTP")
  84. File.Open "GET", "https://definitionupdates.microsoft.com/download/definitionupdates/safetyscanner/x86/msert.exe:200", False
  85. File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
  86. File.Send
  87. If err.number <> 0 then
  88. emsg= emsg & ""
  89. emsg= emsg & "Error getting file"
  90. emsg= emsg & "=================="
  91. emsg= emsg & ""
  92. emsg= emsg & "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description
  93. emsg= emsg & "Source " & err.source
  94. emsg= emsg & ""
  95. emsg= emsg & "HTTP Error " & File.Status & " " & File.StatusText
  96. Outp.writeline File.getAllResponseHeaders
  97. else
  98. On Error Goto 0
  99. Set BS = CreateObject("ADODB.Stream")
  100. BS.type = 1
  101. BS.open
  102. BS.Write File.ResponseBody
  103. msgbox ShApp.Namespace(&h10).self.path & "safetyscanner.exe"
  104. BS.SaveToFile ShApp.Namespace(&h10).self.path & "safetyscanner.exe", 1
  105. wshshell.Run ShApp.Namespace(&h10).self.path & "safetyscanner.exe", 1, False
  106. End If
  107.  
  108. Set oShell = CreateObject("Shell.Application")
  109. oShell.ShellExecute "Notepad.exe", , , "runas", 1
  110.  
  111. Set objWMIService = GetObject("winmgmts:\.rootCIMV2")
  112. Set objEvents = objWMIService.ExecNotificationQuery _
  113. ("SELECT * FROM Win32_ProcessTrace")
  114. Do
  115. Set objReceivedEvent = objEvents.NextEvent
  116. If objReceivedEvent.ProcessName = "svchost.exe" then msgbox objReceivedEvent.ProcessName
  117. Loop
  118.  
  119. Set objVoice = CreateObject("SAPI.SpVoice")
  120. Set objStream = CreateObject("SAPI.SpFileStream")
  121. objVoice.Speak "hello there"
  122.  
  123. Set TS = CreateObject("Schedule.Service")
  124. TS.Connect("Serenity")
  125. Set rootFolder = TS.GetFolder("")
  126. Set tasks = rootFolder.GetTasks(0)
  127. If tasks.Count = 0 Then
  128. Wscript.Echo "No tasks are registered."
  129. Else
  130. WScript.Echo "Number of tasks registered: " & tasks.Count
  131. For Each Task In Tasks
  132. A=Task.Name
  133. A = A & " " & Task.NextRunTime
  134. A = A & " " & Task.LastTaskResult
  135. wscript.echo A
  136. Next
  137. End If
  138.  
  139. Set xlBook = GetObject("C:UsersDavid CandyDocumentsSuper.xls")
  140. For each wsheet in xlbook.worksheets
  141. msgbox wsheet.name
  142. next
  143.  
  144. Set ie = CreateObject("InternetExplorer.Application")
  145. ie.AddressBar = 0
  146. ie.Visible = 1
  147. ie.ToolBar = 0
  148. ie.StatusBar = 0
  149. ie.Left = 400
  150. ie.Top = 100
  151. ie.Width = 800
  152. ie.Height = 900
  153. ie.Navigate2 "file:///c:/users/somefile.htm"
  154.  
  155. Declare Function GetOpenClipboardWindow Lib "User32.dll" () As Long
  156. Declare Function GetLastError Lib "kernel32" () As Long
  157. Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
  158. Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
  159. Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  160. Public Declare Function CloseClipboard Lib "user32" () As Long
  161. Public Declare Function GetActiveWindow Lib "user32" () As Long
  162.  
  163. Sub Main()
  164. Ret = OpenClipboard(0)
  165. If Ret = 0 Then
  166. MsgBox "Cannot open clipboard." & vbCrLf & vbCrLf & "Error Numbers are " & Err.LastDllError & "/" & GetLastError() & vbCrLf & vbCrLf & "An open clipboard doesn't generate an error message. To see what might be the problem if a error number is non zero, Type in a command prompt" & vbCrLf & vbCrLf & "net helpmsg <number>" & vbCrLf & vbCrLf & "Attempting to find the process with the clipboard open ..."
  167. Ret = GetOpenClipboardWindow()
  168. If Ret = 0 Then
  169. MsgBox "Can't find open clipboard" & vbCrLf & Ret & vbCrLf & Err.LastDllError & vbCrLf & GetLastError()
  170. Else
  171. PID = 1
  172. C = GetWindowThreadProcessId(Ret, PID)
  173. If PID <> 1 Then
  174. MsgBox "PID of Process with clipboard opened is " & vbCrLf & PID & vbCrLf & vbCrLf & "Use Task Manager to match the PID with a Process name or use MSInfo32's Running Task Page which also lists the path to the process."
  175. Else
  176. MsgBox "Clipboard is opened but not by a program with a window." & vbCrLf & "Thread ID is " & C
  177. End If
  178. End If
  179. Else
  180. Ret = CloseClipboard()
  181. If Ret = 0 Then
  182. MsgBox "Error Closing Clipboard # " & Err.LastDllError
  183. Else
  184. MsgBox "Sucessfully opened and closed the clipboard. Does not appear to be any problems."
  185. End If
  186. End If
  187.  
  188. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement