Why on earth did MS take away "Record Macro???"

J

JaimeZX

There are so many things that are maddening in 2007.

This is my latest discovery.

Did they need to make room for more Ribbon code or something?

Sorry. /Rant

How can I write in VBcode a macro that will screenshot my Outlook calendar,
paste into PPT, crop it, resize it, and print? My macro writing is largely
limited to recording in Word & Excel 2003, then opening up the VB editor and
cleaning up the excess code that naturally results from an imperfect
recording.

Anyone?
 
J

John Wilson

As well as what Steve said maybe it would be easier to have the macro in
Outlook?

Here's a start with the code

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Dim objppt As Object
Dim objpres As Object
Dim objslide As Object


Sub PrintScreen_to_PPT()
'macro for Outlook
keybd_event &H2C, 1, 0, 0
Set objppt = CreateObject("Powerpoint.Application")
Set objpres = objppt.Presentations.Add(True)
Set objslide = objpres.slides.Add(1, 1)
With objslide.Shapes.Paste
.Top = 0
.Left = 0
.LockAspectRatio = False
.Width = objpres.Pagesetup.slidewidth
.Height = objpres.Pagesetup.slideheight
End With

End Sub
--
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta Oct 11-14 2009
 
J

JaimeZX

Thanks, guys! It's a good start anyway!

I need to figure out how to assign it a keystroke and then write a macro to
crop the thing in PowerPoint, or resize it so that it fills up a page for
printing. But that's not the end of the world. I just can't believe they took
away the record macro function. :p
 
J

JaimeZX

Guys, thanks again. I've been away on business for a little while. I figured
out at least how to make my macro a button on the Outlook toolbar, which I'm
okay with.

The macro does make the calendar the "slide" size in PPT, but I'd like to
crop out everything except the calendar. I tried doing this in Word and
Excel, recording a macro while I cropped-and-resized, but it didn't record
that stuff, so it's just an empty macro when I open up the editor.

Not sure where to go from here. :/

Thanks again!
 
J

JaimeZX

Steve, I sure do appreciate your help! Going on from everything you've
provided so far, I tried to add the following below your code:
With .PictureFormat
.Top = 0
.Left = 0
.Height = 750.01
End With

Seemed logical anyway. I had hoped that this would move the remaining
screenshot to the top left and then size it to fill the slide vertically.
Unfortunately the debugger jumps straight to .Top = 0; I guess I can't move
the thing on the slide like this. Can you offer a final insight into the
resize/move part? Also, if you know how to have it open the print dialogue at
this point, that'd be fantastic.

Thanks again for everything!

Regards,

Jim
 
J

JaimeZX

Aah, I see what you're saying.

First, you're correct that upon paste the code sizes the paste to fit the
slide. Then you gave me additional code for cropping, which I modified
(obviously) so that the image is cropped the the right dimensions.

Now I want to resize the cropped image to fill the slide again. (At least
vertically, and with the aspect ratio locked it should still look okay.)

That's why I tried to grab the code from the original resize for the
subsequent one.

Are you aware of a good online resource or book for this stuff so that I
don't always have to be asking macro questions in this forum? I mean, I
really appreciate your help but I hate to be a burden all the time. That's
why recording macros was so convenient; you could record and then go clean up
the obvious extra stuff it records to streamline the whole thing.

Anyway; grateful as always... Jim
 
J

JaimeZX

Sir:
Thanks for the links; I've been looking at them all morning, although I'm
still looking for more info on the crop/resize bits. That said, here is my
code at this point:
----------------------------------------------
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Dim objppt As Object
Dim objpres As Object
Dim objslide As Object
Dim oSh As Shape

Sub Copy_Calendar()
' macro for Outlook
keybd_event &H2C, 1, 0, 0
Set objppt = CreateObject("Powerpoint.Application")
objppt.Visible = True
Set objpres = objppt.Presentations.Add(True)
Set objslide = objpres.slides.Add(1, 1)
Set oSh = objslide.Shapes.Paste(1)
With oSh
With .PictureFormat
.CropLeft = 145.01
.CropRight = 20.01
.CropTop = 80.01
.CropBottom = 80.1
End With ' picture format
.Top = 0 ' or whatever you like
.Left = 0
End With ' oSh (Shape)
End Sub
---------------------------------
The macro stops after pasting into PPT now and I get "Run-time error '13':
Type mismatch." When I click "Debug," this line is highlighted in yellow:
Set oSh = objslide.Shapes.Paste(1)

I've been looking at all the VB stuff in pptfaq.com trying to figure out
what I'm doing wrong here, but so far I'm coming up blank.

Anyway, at this point I'm thinking the amount of time I'm putting into this
macro may exceed the time it's going to save me over the next year so maybe I
should call it "good enough," althoug at the same time it's become a
challenge part of me wants to defeat. ;-)

If you have further comments I'm very open to them but I'm also willing to
call knock-it-off about now. Hehe

Thanks as always, whichever way you decide!

Jim
 
J

JaimeZX

Ha-HA!!! Victory is ours!!! (Mostly yours.)

I added the reference to PowerPoint (and some other libraries that seemed
relevant.) Still didn't work but I moved the PPT library higher in the
priority list and it worked! Then I moved the resize bit into the With oSh
part. So basically it works exactly as intended at this point. I'll search
around and see if I can't figure out a way to make it open the Print dialogue
at the end, but even if it can't, CTRL+P is pretty easy. ;-)

A final thanks, sir!

Jim

Resulting code:
----------------------------
Sub Copy_Calendar()
keybd_event &H2C, 1, 0, 0
Set objppt = CreateObject("Powerpoint.Application")
objppt.Visible = True
Set objpres = objppt.Presentations.Add(True)
Set objslide = objpres.slides.Add(1, 1)
Set oSh = objslide.Shapes.Paste(1)
With oSh
With .PictureFormat
.CropLeft = 145.01
.CropRight = 20.01
.CropTop = 80.01
.CropBottom = 80.1
End With ' PictureFormat
.Top = 0 ' or whatever you like
.Left = 0
.Height = objpres.Pagesetup.slideheight
End With ' oSh (Shape)
End Sub
 
J

JaimeZX

Printing automatically would be cool, but I like to print my daily calendar
on scrap paper, so I have to go into the printer settings and tell it to
print from the manual feed tray. I also like to check the "scale to paper"
box in the print dialogue so that the calendar uses the full page. For that
reason I'd just prefer to have it open the print dialogue.

Anyway, you have been extremely helpful and I appreciate it!

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top