unexpected problem in VBA Code

  • Thread starter Thread starter Q
  • Start date Start date
Q

Q

Hi, below is most of my code that i am writing for an
automation email to be sent from excel. i've put the (#)
before the code for clarification purposes.

...my slight problem...

the code right now as written runs fine, its sent,
formated correctly, what i want, now line 6 & 8 are
commented, but i want them to be part of the message, but
when i uncomment them, line 13 returns an error, i cannot
for the life of me, figure out the problem, so if anyone
could help or suggest anything it would be truely
appreicated. and if you need the top part of the code
then just ask, thanks in advance.

~q

(1)Msg = Msg & "Please note that the referenced award will
expire on: " & Cells(r, 2) & vbCrLf & vbCrLf 'Insert
End Date

(2)Msg = Msg & "If you require a no-cost extension to
complete the work under this award, and" & vbCrLf

(3)Msg = Msg & "have not already requested an extension
via the ARL Business Office, please" & vbCrLf

(4)Msg = Msg & "contact the contract administrator
identified above at least three (3) weeks" & vbCrLf

(5)Msg = Msg & "end date to do so. If you have already
begun that process," & vbCrLf & vbCrLf

(6)'Msg = Msg & "please disregard this reminder." & vbCrLf

(7)Msg = Msg & "Thank you." & vbCrLf & "The Business
Office" & vbCrLf

(8)'Msg = Msg & "If you have any questions please reply to
this email."

(9)'Format URL to work with Mail program by replacing
spaces with %20 and returns with %0D%0A
Subj = Application.WorksheetFunction.Substitute
(Subj, " ", "%20")

(10)Msg = Application.WorksheetFunction.Substitute
(Msg, " ", "%20")

(11)Msg = Application.WorksheetFunction.Substitute(Msg,
vbCrLf, "%0D%0A")

(12)'Create the URL
URL = "mailto:" & email & "?subject=" & Subj & "&body=" &
Msg

(13)'Execute the URL ie. Start the Mail client
ActiveWorkbook.FollowHyperlink Address:=URL,
NewWindow:=True

(14)'Wait a few seconds ...
Application.Wait (Now + TimeValue("0:00:05"))
Application.SendKeys "%s"

(15)Next r

(16)End Sub
 
oh yeah, you might want to know what the error is, its:

Run-time error '5':
Invalid procedure call or argument

thanks in advance again
 
This used to work for me in XP, but now i've up(down!)graded to Vista, it no longer works in Excel 2003.

The AppActivate fails with runtime error 5.

AppActivate "Quicken Deluxe", True
Application.SendKeys "xxxxxx", True

Change it to this

Application.AutomationSecurity = msoAutomationSecurityLow

AppActivate "Quicken Deluxe", True
Application.SendKeys "xxxxxx", True

And the AppActivate works, but the SendKeys fails silently.

Does anyone know of a solution? Quicken is crap, so this is the only way to automate some of its screens.
 
Back
Top