last day (15 days later) » 

20:22
2
Q: How do I make Outlook 2010 print attachments automatically?

ymarI'm trying to get Outlook 2010 to print attachments automatically apon arrival. I've found this on the internet. The VBA code is Sub LSPrint(Item As Outlook.MailItem) On Error GoTo OError 'detect Temp Dim oFS As FileSystemObject Dim sTempFolder As String Set oFS = New Fi...

If you open the VBA editor, you could set a break point to the beginning of your macro. Then, repeat your test with sending a mail. The editor will pop up und you can execute the macro line by line with F8. This way, we get more details, which line causes the error.
Have you tried this VBA code too? Or maybe this rule-based solution‌​‌​?
@nixda As for the second question, yes a couple of times, mostly in this version, and nothing seemed to happen. But I didn't add any rules here -- I just ran the script as Diane Poremsky advises in her post.
@nixda The error message appears after I press F8 with this line highlighted: "MsgBox Err.Number & " - " & Err.Description".
@nixda The solution in the second link is to a different problem. Rules alone are not enough to print attachments automatically. They only allow to print messages.
The second line On Error GoTo OError is a error handler. Disable it temporarly with a ' in front and repeat the mail test. A different line should now cause the error.
@nixda Now there's no error message at all, and nothing seems to happen. Should I list the lines that actually do get highlighted? (Not all of them do.)
Hi, thank you!
The code skips from "For Each oAtt In Item.Attachments" right to "If Not oFS Is Nothing Then"
20:24
ok mom
Item is a parameter. In other words, its your mail. Hmm, this indicates, that our macro doesn't know the mail
or your mail has no attachment
You can elabote this:
Oh, wait. The last one doesn't have an attachment... I'll try again.
Ok everything I say assumes, you have a break point and a real test with a mail
Ah!
ok I wait
I have no idea what's going on now... I've stopped reveiving the emails...
hm, currently you are trying to fix it?
Yes... Wow, something happened! I need to try again. Sorry!
I'm really confused right now. I got a couple of mails at the same time. I think maybe my connection was slow. One of them seems to have triggered the default printer...
But now it doesn't work again...
20:34
ok Im confused too :D
Okay one more attempt!
:)
Okay...
Now the email definitely does have the attachment.
And nothing happens.
The code skips between the lines I mentioned earlier
"For Each oAtt In Item.Attachments" right to "If Not oFS Is Nothing Then"
In this case, when you triggered the mail with an attachment: You can right click on "item" and select "add watch". Now with CTRL+G you open a "direct window" to view all properties of item (your mail)
There has to be something called "attachments"
do I have to highlight "item"?
No, only right click it
I have the options: "watch expression", "break when value is true", "break when value changes". The frst one?
20:42
ah ok, maybe they call it other in outlook VBA editor. I have only Excel VBA editor in front of me
I think its "Watch expression"
okay
ctrl+g open a window titled "immediate"
*opened
ah mom
wrong shortcut
menu bar > view > watch window
Found it?
okay, it's open (it opened earlier, without ctrl+g)
Now send yourself amail and let the macro be triggered. Dont forget a break point
Right after that, go to the watch window and look through the propteries of "item"
*properties
okay, I have a tree. I clicked the plus sign next to "item" to expand.
20:47
correct
I see a lot of things.
something called "attachments"?
Oh, there's attachments too.
:)
wohow
and is this subtree empty ?
no
The branches are:
application, class, count, parent, session, item 1.
20:49
"Item 1" is our winner
if you have 2 attachments. there would be item 1 and item 2
Okay, it expands too.
okay :)
thats enough. We know what we wanted
there IS an atachment and the macro should be able to see it
okay, I see
now the question is, why the for-loop doesn't loop through the attachments which is stored under "Item.Attachments"
Hey!
20:52
Can you please watch "oAtt" and do the same procedure again`Does it gets a value when the line "For Each oAtt In Item.Attachments" is executed?
say I just ran it again...
yes?
sorry, without the "say"
It worked!
repeat it
i dont trust it :D
Okay. I have no idea what's going on.
20:53
So, the printer started?
yes...
But not this time!
geez...
I mean the "save as" window popped up, because it's not a real printer.
But now it skipped the improtant lines again, and nothing happened
And Outlook sees an attachment there still.
Wait, have you stopped the macro with the break point and forgot to stop it completely? Break point = pause, so every second mail send can't trigger the macro because its still running
hmm
I just ran the macro to the last line.
Until it stopped highlighting anything
and then sent the new mail
ok, thats the right way
geez... Let me try it again, I don't trust myself.
For heaven's sake...
I didn't send a new mail...
Just kept going with the F8 thing
It started over, and now the printer is triggered
21:00
Now you know it. Always this procedure: set break point > send mail > let macro be triggered > finish the macro with F8
Don START the macro with F8
So, finally everthing is working?
Okay. I'll start over. The editor doesn't highlight anything in yellow. Just the breakpoint in red
Is this the right starting point?
correct, personally I prefer to set the break point an the first line Sub LSPrint(Item As Outlook.MailItem)
*on
Yes, that's where my breakpoint is set
okay. I'll send the mail.
alright. the script is running, the first line is highlighted in yellow now.
so I start going with the F8
It've gone through the whole thing and it didn't work.
merde
okay, I'll keep pressing f8
I can't, it just gives me the bell sound and nothing happens.
21:06
Was says "Watch expression" on item > attachments ?
Was the loop again skipped?
yes, it was. And the attachments node is not expandable now.
the script is not running though
Sorry!
You see attachments only when the script was triggered correctly with an mail+attachment
I mean the "Item" node is not expandable
but there is an attachment
I can see it in outlook
Yeah, if I understand you right, you haven't triggered the macro first with an mail send event :)
huh? I don't understand...
say Okay, I'm trying again
sorry for this "say", it's a habit from a different place
21:11
We have already done this step 5 minutes ago. I just want you to repeat it. send a mail > look if "item 1" is expandable and report it to me
Okay. I've done it.
It is expandable during the run
ok mom
but the loop was skipped again
Ah thats the important info
VBA does have an attachment but the loop is skipped
okay
But not always :/
21:13
There has to be something wrong with the code, not with your execution or mail
but it does work sometimes!
yea thats the strange point
I have no clue
It's okay :)
Thank you very much, I've learned a lot anyway.
I'm really sorry.
it's no trouble. I'll sleep on it and try again.
21:16
The only logic explanation must be, that the parameter "item" (your mail) is differs
-is
But I assume you always use the same mail same attachment, same procedure
you mean I should look at how the parameter changes during the run?
You could look if the parameter "item 1" changes BETWENN runs (one working and one failing run
*between
Yes I do. I the title and the content differ (they're like "dsfsf"), but that I believe shouldn't matter. Other things seem to be the same
Okay
I'll try that :)
title shouldn matter, thats right
the attached file is always the same
21:19
ok
maybe someone will answer the question then :) I'll post an update with a summary of these experiments.
Thats fine
maybe someone'll have something to say
okay :)
At least you learned how to debug VBA
I did! Thanks a lot! :)
21:20
break point + F8 + Watch expression + Watch window :)
Ok, then. My apologiez again and good night. Its late here :)
It seems way easier than with any programming language I've tried.
okay!
Indeed it is"
good night
bye
:)
bye

last day (15 days later) »