Chris Wilson
asked on
Trying to get my Excel workbook to upload multiple sheets into one Outlook email main body?
Hi, Im hoping someone can help. I am trying gto resolve an issue I have had for a few weeks now. I created an Excel workbook with VBA which took screen captures from multiple Excel sheets within the workbook. I am using Windows 8 and Office 2013. The script works absolutely fine. But on Windows 10, Office 2016 it doesnt. I managed to resolve the issue but now when i add the code to take captures from multiple sheets it does not work. Please can someone help.
The code is as follows.
Please can someone help me write into this code screen capture of multiple sheets from one excel document. The sheets are named as followed:-
Sheet 1 is called 1 Year Option and the cell range is "B2 - O38"
Sheet 2 is called 2 Year Option and the cell range is "B2 - O38"
Sheet 3 is called 3 Year Option and the cell range is "B2 - O38"
Sheet 4 is called Support Options and the cell range is "A1 - A31"
Sheet 5 is called System Requirements and the cell range is "B2 -I22"
If you need further information please let me know.
Thanks in advance,
Chris
The code is as follows.
Private Sub CommandButton1_Click()
'Copy range of interest
Dim r As Range
Set r = Range("B2:O38")
r.Copy
'Paste as picture in sheet and cut immediately
Dim p As Object
Set p = ActiveSheet.Pictures.Paste
p.Cut
'Open a new mail item
Dim outlookApp As Object
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Object
Set outMail = outlookApp.CreateItem(0) '
'Get its Word editor
outMail.Display
Dim wordDoc As Object
Set wordDoc = outMail.GetInspector.WordEditor
'Paste picture
wordDoc.Range.Paste
wordDoc.InlineShapes.Item(1).ScaleHeight = 100
wordDoc.InlineShapes.Item(1).ScaleWidth = 100
End Sub
Please can someone help me write into this code screen capture of multiple sheets from one excel document. The sheets are named as followed:-
Sheet 1 is called 1 Year Option and the cell range is "B2 - O38"
Sheet 2 is called 2 Year Option and the cell range is "B2 - O38"
Sheet 3 is called 3 Year Option and the cell range is "B2 - O38"
Sheet 4 is called Support Options and the cell range is "A1 - A31"
Sheet 5 is called System Requirements and the cell range is "B2 -I22"
If you need further information please let me know.
Thanks in advance,
Chris
I am not a VBA expert but I am going to ask. I see line 4 you have a range set, which is for Sheets 1- 3 but for Sheets 4 and 5 I do not see their ranges in the code. Is there a reason for that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Bill, I like the way you put comments in your code to let us know what it does. 2 Thumbs up!
ASKER
Hi Bill, Yes we did but it didnt work (for reasons no one could work out) in Windows 10 Office 2016. I am using Windows 8 Office 2013 which it worked well with. I checked all references and they were all set. Amended settings in Outlook Trust Centre but wouldnt work.
Odd, it works fine in a test for me here (although I don't have your actual spreadsheet here, just a test one I worked up).
Do you get any errors, what are the symptoms of "didn't work" ?
»bp
Do you get any errors, what are the symptoms of "didn't work" ?
»bp
ASKER
Hi Bill, Yes when i click on the VBA to run it I get an error message stating - Compile Error, Cant find project or librarty. Ive attached a screenshot for your information. Do you want me to send you the actual Excel File so you can check the tool references?
VBA-Project-Library-Error.docx
VBA-Project-Library-Error.docx
I suspect it's related to References, if you go to Tools, References, can you take a capture there, and look for warnings.
»bp
»bp
ASKER
Hi Bill,
Please accept my apologies for the delayed response. I have been away from the office the last few weeks. Please can you advise where in references i look for warnings as i cannot see this?
Please accept my apologies for the delayed response. I have been away from the office the last few weeks. Please can you advise where in references i look for warnings as i cannot see this?
ASKER
Hi Bill,
Please advise how i close this question. It is not working our side still but it is not the code as i tested it at home and it worked fine. Its a setting our side that is blocking this from working.
It will not let me close this question and award the points?
Please advise how i close this question. It is not working our side still but it is not the code as i tested it at home and it worked fine. Its a setting our side that is blocking this from working.
It will not let me close this question and award the points?
Chris,
I requested a close which I think is in line with what you would want. A moderator will review and should close in a day or two. If you disagree with the way I proposed closing then post a comment here and "Object".
»bp
I requested a close which I think is in line with what you would want. A moderator will review and should close in a day or two. If you disagree with the way I proposed closing then post a comment here and "Object".
»bp