Civinfo

13.jpg
This thread is about: technical excel macro help please!, it's in Any non Civic chat here please! at the Honda Civic forum Civinfo; got a fabby macro running in my excel spreadsheet, but now I've hit a problem And I'm hoping some wiz out there might be able ...

Help Search Stickers Surveys Wiki Forum
Go Back   Civinfo > Off topic > Any non Civic chat here please!

Reply
 
LinkBack Thread Tools Display Modes
Old 19th October 2006, 09:18   #1 (permalink)
Super Moderator
Civinfo master
 
TTDegs's Avatar
 
Join Date: 4th August 2006
Location: Cardiff WALES
Posts: 5,638
Thanks: 0
Thanked 1 Time in 1 Post
technical excel macro help please!



got a fabby macro running in my excel spreadsheet, but now I've hit a problem
And I'm hoping some wiz out there might be able to help!

I've got a sheet with all my data on, sorted by outlet.

Each seperate outlet needs to get the data for just their own store.

I can get the macro to dynamically extract each store's info into a new sheet without a problem - BUT

I now need to send this data in an email.

If (under macro control) I create an email with an attachment, I loose control from the macro (cos the PC is now running Outlook)
and even the email address (copied by macro from the appropriate cell) refuses to paste into the To box (even manually)

If I create the email as a 'for review' I can (manually) paste the email address in, but again, not by the macro as it's not 'in control' of the email


does anyone have any ideas please?

I need to make this a 'push the button and forget' operation, as it's got to work for muppet users - sorry, I mean it needs to be foolproof

any suggestions gratefully received!


But I'm constrained to using excel and Outlook, as it's a work app
TTDegs is offline   Reply With Quote
Old 19th October 2006, 13:02   #2 (permalink)
Supporter
Triangular Exhaust
 
Glass Spider's Avatar
 
Join Date: 15th June 2006
Location: London ENGLAND
Posts: 308
Thanks: 1
Thanked 0 Times in 0 Posts
are you using the CreateItem(olMailItem) method to create your email?

mind you if i were you i'd get into access and run queries and stuff form there, I have a database that puts data out to email and is one button muppet proof job
Glass Spider is online now   Reply With Quote
Old 19th October 2006, 13:28   #3 (permalink)
Administrator
Civinfo guru
 
Pottsy's Avatar
 
Join Date: 10th April 2006
Location: Leics ENGLAND
Posts: 4,985
Thanks: 8
Thanked 91 Times in 49 Posts
I have had to do this before and I remember it all getting a bit unstuck. Ended up coding it in VB6 instead...

But here's a bit pinched from a quick Google...

Code:
Sub SendEmail()

ESubject = "This is a test email"
SendTo = "Some_Address@ADomain.com"
CCTo = "Different_Address@ADomain.com"
Ebody = "Testing VBA's ability to send an email."
NewFileName = "C:\My Documents\TestFile.xls"

Set App = CreateObject("Outlook.Application")
Set Itm = App.CreateItem(0)
With Itm
.Subject = ESubject
.To = SendTo 
.CC = CCTo
.Body = Ebody 
'.Attachments.Add (NewFileName) ' Must be complete path
'.Display ' This property is used when you want
' the user to see email and manually send. Then 
' comment out rest of code except “End With” statement
' and "End Sub" statement.
.send
End With
Set App = Nothing
Set Itm = Nothing
End Sub
The "complete path" might be a nightmare though, and I bet Outlook does that "something is trying to send an email, what do you want to do?" question.
Pottsy is online now   Reply With Quote
Old 19th October 2006, 13:58   #4 (permalink)
Locking Wheelnut
 
smiffy's Avatar
 
Join Date: 5th June 2006
Location: Buxton, UK ENGLAND
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
I've created an App using very similar logic to this, except I stopped at the .display, so the user could add text if necessary, then click on Send.

Can't remember why now, but I also had, at the beginning:

On Error Resume Next
Set OutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then 'Outlook not running - start it
Me.MousePointer = vbHourglass
Err.Clear
Set OutlookApp = CreateObject("Outlook.Application")
DoEvents
If Err <> 0 Then
MsgBox "Please start Outlook then try again"
Err.Clear
End If
Me.MousePointer = vbDefault
End If
On Error GoTo 0

I think the CreateObject failed if the user already had Outlook open.
smiffy is offline   Reply With Quote
Old 19th October 2006, 14:03   #5 (permalink)
Supporter
Triangular Exhaust
 
Glass Spider's Avatar
 
Join Date: 15th June 2006
Location: London ENGLAND
Posts: 308
Thanks: 1
Thanked 0 Times in 0 Posts
On Error Resume Next, thats one of my favourites! lol
Glass Spider is online now   Reply With Quote
Old 19th October 2006, 14:05   #6 (permalink)
Locking Wheelnut
 
smiffy's Avatar
 
Join Date: 5th June 2006
Location: Buxton, UK ENGLAND
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, very 20th Century (early), isn't it? Works, though!
smiffy is offline   Reply With Quote
Old 19th October 2006, 16:22   #7 (permalink)
Smell My Cheese!
Rocketship door handle
 
richierich's Avatar
 
Join Date: 17th May 2006
Location: Bicester, Oxfordshire ENGLAND
Posts: 1,847
Thanks: 0
Thanked 0 Times in 0 Posts
And I thought Esperanto never took off.
richierich is offline   Reply With Quote
Old 19th October 2006, 17:06   #8 (permalink)
Super Moderator
Civinfo master
 
TTDegs's Avatar
 
Join Date: 4th August 2006
Location: Cardiff WALES
Posts: 5,638
Thanks: 0
Thanked 1 Time in 1 Post
many thanks for all the replies!

I've actually taken inspiration from each of them, scratched my head a lot, perused the (fairly useless!) help topics, and come up with...

macros copies relevant data into new worksheet

B1 contains the report title = "Report for 2006/10/18"
B3 contains (dynamically) the email address of the recipients
C3 contains (dynamically) the store name

Code:
emailstore = range("b3").value
emailsubj = range("b1").value + " - " + range("c3").value
activeworkbook.sendmail Recipients:=emailstore, subject:=emailsubj
and job is jobbed

MANY thanks again for all the replies - much appreciated!
TTDegs is offline   Reply With Quote
Reply

  Civinfo > Off topic > Any non Civic chat here please!

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: technical excel macro help please!
Thread Thread Starter Forum Replies Last Post
Technical Specifications davidj241 Wiki Article Discussion 2 17th July 2008 11:08
Faults Technical Hints and Tips m4rky Engines and Transmission 12 21st October 2007 11:45
HondaJet Flight Demonstration and Technical Briefing to be Held at EAA AirVenture Osh Honda News Feed Honda News 0 2nd November 2006 22:44


All times are GMT +1. The time now is 21:47.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
vB.Sponsors
Site owned by Andrew Potts - nothing to do with Honda!

Hosting by Vidahost

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46