![]() |
|
||||||||
| Site Links |
| Consulting |
| Knowledge Base |
| Training |
| Forum |
| Articles |
| Resources |
| Products |
| Cool Tools |
| Contact |
| About Us |
| Go to Page... |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
|
Extract lines and print
Hi !
I need to do a Outlook VBA project. I have used about 8 hours of google and haven't got even started. Normally with Excel the thing would be done allready Here is an image of the Email(revome the () around dots): www(.)robokara(.)fi/images/image.jpg I have marked what text I would like to extract from the mail. This text would be printed out from a label printer like this: Kari Nurmi Tapiolantie 21 B18 60150 SEINÄJOKI I can set the label printer as a default printer for that PC, so I think that just a normal print command would do. I have made a rule that regognices these mails and forwards them to right persons. The same rule also runs a patch that start our Disc Bublisher wich will make a DVD. The same rule should run the Script that prints the label. Things I need help with: How to make a VBA that finds nimi: from the Body-element and get's the rest of the line to an integer. Could you guys help me? |
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#2 |
|
|
VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 03:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#3 |
|
|
Thanks for the code!
What do I need to put here: I need to put something there or else it will not show the VBA in the Rule dialog box? Cheers! |
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#4 |
|
|
I found this on the internet, but it didin't help:
I can now select it from the Run Script dialog when making a rule, but it only process mail, wich is higlighted at outlook. Example a mail that has been last viewed. It does not process new mail. Is it the MyMail As MailItem that is causing it? |
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#5 |
|
|
Here the modified script so it would run with any new message that arrives. Another possibility would be by using withevents in the thisoutlooksession. This option works without any rules. You define a folder to watch for every new mail (inbox in this case) and use select case or if structure to determine what to do with a new message.
We are using mymessage as variable instead of mymail. The reason why it would only work on the selected mail is ... because it was designed like this (1st version at least). Now it should work if you define your rule. VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 03:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#6 |
|
|
Thanks, this seems to work
One more thing I would like to ask: Sometimes there is a Yritys: field on these forms. How do I add it so, that it will be printed only when it appears on the code? I tried to add it but I get an error, Invalid Procedure call or argument VBA:
VBA tags courtesy of www.thecodenet.com
I changed the postinro to 10, so there will not be an empty space at the line. The Shell command is a comment at this point, so I can test this with out using expensive labes. |
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#7 |
|
|
It was because the Yritys was writen with capital Y. It works now since I change it to y.
Now it crashes, if there is no yritys, on the form. I need a statement? |
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#8 |
|
|
VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 03:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#9 |
|
|
It now runs regardless if Yritys has anything, but it wont print the Yritys.
So if there is nothing on it, or if there is, the label is the same. Edit: I moved the Yritys to rigth place: VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#10 |
|
|
Dear Ekto,
Watch the capital letters. You said yourself that it needed to search for yritys ... Charlize |
|
Local Time: 03:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#11 |
|
|
Yes, thanks! Now it works!
Do you know if there is different types of vbCrLf? I think that the printer is not neceserly realyzing that. We had similar problem with one PHP system... Last edited by ekto : 03-09-2012 at 01:48 AM. |
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#12 |
|
|
is enter with a line feed I think. Instead of that, you could use
for enter and if I'm not mistaken,
for the linefeed. But I'm not an expert on that. If it works ... don't break it
.Charlize |
|
Local Time: 03:19 AM
Local Date: 05-25-2013 Location:
|
|
|
|
#13 |
|
|
I got it working by installing newer version of the printer software. Thanks Charlize, you have been a real help.
One more quoestion, Since Outlook is running on a PC wich is not used normally, I would like to add some error handling to the code. It would be nice, that if there is an error, it would just jump over that mail, and try the next. I tried to use On error GoTo, but I didn't sucseed. |
|
Local Time: 05:19 AM
Local Date: 05-25-2013 Location:
|
|
![]() |
| Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|


