#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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! |
#3
|
||||
|
||||
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] |
#4
|
||||
|
||||
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] |
#5
|
|||
|
|||
Since I was not able to get help from one forum, I tried another. Is that really so bad?
|
#6
|
||||
|
||||
Obviously you haven't read what in the link. Instead of taking umbrage, read it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
Having Touble Finding Word File When Trying to Attach to Email | freetibet213 | Word | 3 | 12-28-2011 05:26 AM |
How to type into a screenshot in word? | greenwall | Word | 2 | 11-24-2011 02:14 PM |