borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Enumerated type under VBA for office 97)Next Topic (Excel VBA Help Please) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : SENDKEYS error
Poster Message
Elderon
Level: Guest


icon SENDKEYS error

Hi,

I have some code to send some numbers to the calculator (aprt of a sample).
Its in a loop
SENDKEYS I "{+}", TRUE

I get the error message:
Expected variable or Procedure not Project.
Anybody able to help?

08-05-2003 at 01:45 PM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: SENDKEYS error

Any chance of posting a bit more of the code up there please?

PS I assume the syntax error was accidental.



The following code worked for me. I put the calc.exe as the foreground app and the vb code put the values into the calculator.

Private Sub Timer1_Timer()

Dim i As Integer

For i = 1 To 20

    SendKeys i & "{+}", True
Next i

End Sub


[Edited by steve_w on 08-05-2003 at 03:23 PM GMT]

08-05-2003 at 02:48 PM
View Profile Send Email to User Show All Posts | Quote Reply
Elderon
Level: Guest

icon Re: SENDKEYS error

Hi -

thanks for your reply - the syntax error was a mistake.  he code is from the help and gives me the error as stated even with the correct syntax.

What I'm trying to do (this may not be the way to do it), is to automate the sending of e-mails based on a timer object.

Thus the app will have data fed into it and then at periodic intervals it will automaticalyy send emails in the format

<standard text><variable text from table><standard text>

I wish to use Outlook as my e-mail sender and receiver.  Dont want masses of code.  I have been todl that it might be better to use another method but am not aware of one thats easy.

12-05-2003 at 01:04 PM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: SENDKEYS error

You could try using the mapi controls instead of using the sendkeys.

Select the Microsoft MAPI Controls 6.0 from the Components screen (Ctrl - T)

This will give you two controls MapiSession and MapiMessage. Put both of these onto your form. Then use the following code.

In your timer function use the following code.

    
  

    MAPISession1.UserName = "<your login name>"
    MAPISession1.SignOn

    MAPIMessages1.SessionID = MAPISession1.SessionID
    MAPIMessages1.Compose
    MAPIMessages1.RecipAddress = "<to email address>"
    MAPIMessages1.ResolveName
    MAPIMessages1.MsgSubject = "Hello"
    MAPIMessages1.MsgNoteText = "World"
    MAPIMessages1.Send

    MAPISession1.SignOff
    



Good luck

[Edited by steve_w on 19-05-2003 at 12:23 PM GMT]

19-05-2003 at 12:20 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : SENDKEYS error
Previous Topic (Enumerated type under VBA for office 97)Next Topic (Excel VBA Help Please) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder