View Single Post
 
Old 05-28-2014, 08:46 AM
PANTECH PANTECH is offline Windows 7 64bit Office 2007
Novice
 
Join Date: May 2014
Posts: 4
PANTECH is on a distinguished road
Default Word 2010 VBA userform screen shot will not email

The below code works with Word 2007 but will not work with Word 2010. What needs to be changed to make the userform screen shot go to the user via email.

Code:
 
Option Explicit
 
Private Sub CommandButton1_Click()
    Dim olApp As Object
    Dim olMsg As Object
    Dim olRec As Object
    Dim olDoc As Document
    On Error Resume Next
    Set olApp = GetObject(Class:="Outlook.Application")
    If olApp Is Nothing Then
        Set olApp = CreateObject(Class:="Outlook.Application")
        If olApp Is Nothing Then
            MsgBox "Can't start Outlook!", vbCritical
            Exit Sub
        End If
        olApp.Session.Logon
 
    End If
    On Error GoTo ErrHandler
    Call AltPrintScreen
    DoEvents
    Set olMsg = olApp.CreateItem(0)
    Set olRec = olMsg.Recipients.Add("myemailaddress")
    olMsg.Subject = "WALKAROUND"
 
    olMsg.Display
    Set olDoc = olApp.ActiveInspector.WordEditor
    olDoc.Content.Paste
    olDoc.Content.InsertParagraphAfter
    olDoc.Content.InsertAfter "Here you go"
 
    olMsg.Send
ExitHandler:
    On Error Resume Next
    Exit Sub
ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
End Sub
 
Private Sub SpinButton1_Change()
    TextBox1.Text = SpinButton1.Value
    SpinButton1.Min = 0
    SpinButton1.Max = 9
End Sub
Private Sub SpinButton2_Change()
    TextBox2.Text = SpinButton2.Value
    SpinButton2.Min = 0
    SpinButton2.Max = 9
End Sub
Private Sub SpinButton3_Change()
    TextBox3.Text = SpinButton3.Value
    SpinButton3.Min = 0
    SpinButton3.Max = 9
End Sub
Private Sub SpinButton4_Change()
    TextBox4.Text = SpinButton4.Value
    SpinButton4.Min = 0
    SpinButton4.Max = 9
End Sub
Private Sub UserForm_Initialize()
    Dim ws As WdWindowState
    With Application
        ' Store current window state in variable
        ws = .WindowState
        ' Maximize application
        .WindowState = wdWindowStateMaximize
        ' Resize userform to application size
        Me.Width = .Width
        Me.Height = .Height
        ' Restore the application's original window state
        .WindowState = ws
    End With
End Sub
Sub CreateShortCut()
    Dim oWSH As Object
    Dim oShortcut As Object
    Dim sPathDeskTop As String
    Set oWSH = CreateObject("WScript.Shell")
    sPathDeskTop = oWSH.SpecialFolders("Desktop")
    Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
        ActiveDocument.Name & ".lnk")
    With oShortcut
        .TargetPath = ActiveDocument.FullName
        .Save
    End With
    Set oWSH = Nothing
End Sub

Thank you!
Reply With Quote