Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-16-2014, 12:15 PM
PANTECH PANTECH is offline Word7 VBA- need userform screenshot to attach to email Windows 7 64bit Word7 VBA- need userform screenshot to attach to email Office 2007
Novice
Word7 VBA- need userform screenshot to attach to email
 
Join Date: May 2014
Posts: 4
PANTECH is on a distinguished road
Default Word7 VBA- need userform screenshot to attach to email

I need to be able to complete all fields on the userform then click the Submit command button and automatically have the screenshot of only the userform saved as an attachment to a predifined email. The below code will send an email attachment but there is no screen shot.



Please help

Code:
Private Sub Workbook_Open()
Application.Visible = True
frmWALKAROUND.Show
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 commandButton1_Click()
Dim OL As Object
Dim EmaiItem As Object
Dim Doc As Document
 
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save
 
With EmailItem
.Subject = "Walkaround"
.To = "myemailaddress"
.Importance = olImportanceNormal
.Attachments.Add Doc.FullName
.Send
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
Application.ActiveDocument.Close
End Sub
Reply With Quote
  #2  
Old 05-28-2014, 08:46 AM
PANTECH PANTECH is offline Word7 VBA- need userform screenshot to attach to email Windows 7 64bit Word7 VBA- need userform screenshot to attach to email Office 2007
Novice
Word7 VBA- need userform screenshot to attach to email
 
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
  #3  
Old 05-30-2014, 06:02 AM
macropod's Avatar
macropod macropod is offline Word7 VBA- need userform screenshot to attach to email Windows 7 32bit Word7 VBA- need userform screenshot to attach to email Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code calls a sub named AltPrintScreen, via:
Call AltPrintScreen
but you haven't included that.

Furthermore, your code has Workbook_Open, but that's for Excel, not Word. What application is this code for?

PS: Please don't post code that isn't directly connected to the problem. You've posted a bunch of code relating to spin buttons, plus your UserForm_Initialize and CreateShortCut code, but there's nothing to indicate how or whether they're relevant - only the CommandButton1_Click and the missing AltPrintScreen subs appear relevant.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 05-30-2014, 11:05 PM
macropod's Avatar
macropod macropod is offline Word7 VBA- need userform screenshot to attach to email Windows 7 32bit Word7 VBA- need userform screenshot to attach to email Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://www.eileenslounge.com/viewtopic.php?f=30&t=16578
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 06-02-2014, 05:24 AM
PANTECH PANTECH is offline Word7 VBA- need userform screenshot to attach to email Windows 7 64bit Word7 VBA- need userform screenshot to attach to email Office 2007
Novice
Word7 VBA- need userform screenshot to attach to email
 
Join Date: May 2014
Posts: 4
PANTECH is on a distinguished road
Default

Since I was not able to get help from one forum, I tried another. Is that really so bad?
Reply With Quote
  #6  
Old 06-02-2014, 05:27 AM
macropod's Avatar
macropod macropod is offline Word7 VBA- need userform screenshot to attach to email Windows 7 32bit Word7 VBA- need userform screenshot to attach to email Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Obviously you haven't read what in the link. Instead of taking umbrage, read it.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word7 VBA- need userform screenshot to attach to email Is it possible to take an input from a UserForm in one document to a UserForm in a do BoringDavid Word VBA 5 05-09-2014 09:08 AM
The Best Way to Decolor a Screenshot SQLUSA Word 1 07-15-2012 09:08 PM
attach multiple excel files to same email using send to option cbtac Excel 0 01-04-2012 07:20 AM
Word7 VBA- need userform screenshot to attach to email Having Touble Finding Word File When Trying to Attach to Email freetibet213 Word 3 12-28-2011 05:26 AM
Word7 VBA- need userform screenshot to attach to email How to type into a screenshot in word? greenwall Word 2 11-24-2011 02:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft