PC Review


Reply
Thread Tools Rate Thread

Can I learn VBA quickly and how?

 
 
=?Utf-8?B?c3VlMnVr?=
Guest
Posts: n/a
 
      7th Nov 2007
This was my original question on the Excel discussion group:
"I have a couple of rental properties abroad and have a simple Excel
spreadsheet with details of the booking, client, deposit paid, date balance
due etc. Is there any way that this can be linked to Outlook as a task or in
the calendar to alert me on the due date to remind me to chase the client for
payment of their balance?"
It was suggested that I look for a VBA solution - is this something I can do
myself, learn quickly, where do I start, any suggestions? (I did some
programming briefly about 20 years ago!!!!)
 
Reply With Quote
 
 
 
 
ilia
Guest
Posts: n/a
 
      7th Nov 2007
If you have some programming experience, it should be a breeze. My
recommendation would be to look at some introductory material for
Visual Basic 6.0, as this will give you both the working basics of the
language, and also basics of programming. Another good choice would
be Excel 200x VBA Programmer's Reference or Excel 200x VBA Power
Programming, both of which start at the beginning and provide VBA-
specific material. Any of these references will also give you a
sufficient introduction to how classes work - critical for VBA,
because just about everything is a class object or a member of one.

Here's an example of a simple spreadsheet application working with
Outlook. Column A contains task names; column B contains due dates.
Placed inside a worksheet's code module, it processes input in cells
B2:B50 (leaving row 1 for headers), and creates an outlook task item.
I put comments to help you figure out what's going on. Try it out:


Private Sub Worksheet_Change(ByVal Target As Range)
' only using range B2:B50
If Not (Intersect(Target, Me.Range("B2:B50")) _
Is Nothing) Then

' these are the objects we're working with
Dim objOutlook As Object
Dim objItem As Object
Dim blnOutlookRunning As Boolean
Dim dtDueDate As Date

' make sure a date is entered
On Error Resume Next
dtDueDate = Target.Value
On Error GoTo 0

' if a date is not entered,
' alert user and clear input
If dtDueDate = 0 Then
Call MsgBox("Enter a date!", vbExclamation)
Application.EnableEvents = False
Target.Clear
Application.EnableEvents = True
Exit Sub
End If

' check to see if outlook is already running
On Error Resume Next
Set objOutlook = GetObject(, _
"Outlook.Application")
blnOutlookRunning = True
On Error GoTo 0

' if outlook is not running, start it
If objOutlook Is Nothing Then
blnOutlookRunning = False
Set objOutlook = _
CreateObject("Outlook.Application")
End If

' create a new item
Set objItem = _
objOutlook.CreateItem(olTaskItem)

' set item properties based on spreadsheet
With objItem
.DueDate = dtDueDate
.Subject = "Get " & Target.Offset(0, -1).Value _
& " done by " & Target.Value
.Save
End With

' quit outlook if it wasn't running
If Not blnOutlookRunning Then
objOutlook.Quit
End If
End If
End Sub



On Nov 7, 10:52 am, sue2uk <sue...@discussions.microsoft.com> wrote:
> This was my original question on the Excel discussion group:
> "I have a couple of rental properties abroad and have a simple Excel
> spreadsheet with details of the booking, client, deposit paid, date balance
> due etc. Is there any way that this can be linked to Outlook as a task or in
> the calendar to alert me on the due date to remind me to chase the client for
> payment of their balance?"
> It was suggested that I look for a VBA solution - is this something I can do
> myself, learn quickly, where do I start, any suggestions? (I did some
> programming briefly about 20 years ago!!!!)



 
Reply With Quote
 
ilia
Guest
Posts: n/a
 
      7th Nov 2007
Oops! One correction. Replace this:

> ' create a new item
> Set objItem = _
> objOutlook.CreateItem(olTaskItem)



with this:

' create a new item
Set objItem = _
objOutlook.CreateItem(3)



On Nov 7, 3:37 pm, ilia <iasaf...@gmail.com> wrote:
> If you have some programming experience, it should be a breeze. My
> recommendation would be to look at some introductory material for
> Visual Basic 6.0, as this will give you both the working basics of the
> language, and also basics of programming. Another good choice would
> be Excel 200x VBA Programmer's Reference or Excel 200x VBA Power
> Programming, both of which start at the beginning and provide VBA-
> specific material. Any of these references will also give you a
> sufficient introduction to how classes work - critical for VBA,
> because just about everything is a class object or a member of one.
>
> Here's an example of a simple spreadsheet application working with
> Outlook. Column A contains task names; column B contains due dates.
> Placed inside a worksheet's code module, it processes input in cells
> B2:B50 (leaving row 1 for headers), and creates an outlook task item.
> I put comments to help you figure out what's going on. Try it out:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> ' only using range B2:B50
> If Not (Intersect(Target, Me.Range("B2:B50")) _
> Is Nothing) Then
>
> ' these are the objects we're working with
> Dim objOutlook As Object
> Dim objItem As Object
> Dim blnOutlookRunning As Boolean
> Dim dtDueDate As Date
>
> ' make sure a date is entered
> On Error Resume Next
> dtDueDate = Target.Value
> On Error GoTo 0
>
> ' if a date is not entered,
> ' alert user and clear input
> If dtDueDate = 0 Then
> Call MsgBox("Enter a date!", vbExclamation)
> Application.EnableEvents = False
> Target.Clear
> Application.EnableEvents = True
> Exit Sub
> End If
>
> ' check to see if outlook is already running
> On Error Resume Next
> Set objOutlook = GetObject(, _
> "Outlook.Application")
> blnOutlookRunning = True
> On Error GoTo 0
>
> ' if outlook is not running, start it
> If objOutlook Is Nothing Then
> blnOutlookRunning = False
> Set objOutlook = _
> CreateObject("Outlook.Application")
> End If
>
> ' create a new item
> Set objItem = _
> objOutlook.CreateItem(olTaskItem)
>
> ' set item properties based on spreadsheet
> With objItem
> .DueDate = dtDueDate
> .Subject = "Get " & Target.Offset(0, -1).Value _
> & " done by " & Target.Value
> .Save
> End With
>
> ' quit outlook if it wasn't running
> If Not blnOutlookRunning Then
> objOutlook.Quit
> End If
> End If
> End Sub
>
> On Nov 7, 10:52 am, sue2uk <sue...@discussions.microsoft.com> wrote:
>
>
>
> > This was my original question on the Excel discussion group:
> > "I have a couple of rental properties abroad and have a simple Excel
> > spreadsheet with details of the booking, client, deposit paid, date balance
> > due etc. Is there any way that this can be linked to Outlook as a task or in
> > the calendar to alert me on the due date to remind me to chase the client for
> > payment of their balance?"
> > It was suggested that I look for a VBA solution - is this something I can do
> > myself, learn quickly, where do I start, any suggestions? (I did some
> > programming briefly about 20 years ago!!!!)- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
=?Utf-8?B?c3VlMnVr?=
Guest
Posts: n/a
 
      7th Nov 2007
Awesome! Thank you so much for your time. That's given me the confidence to
get started!

"ilia" wrote:

> Oops! One correction. Replace this:
>
> > ' create a new item
> > Set objItem = _
> > objOutlook.CreateItem(olTaskItem)

>
>
> with this:
>
> ' create a new item
> Set objItem = _
> objOutlook.CreateItem(3)
>
>
>
> On Nov 7, 3:37 pm, ilia <iasaf...@gmail.com> wrote:
> > If you have some programming experience, it should be a breeze. My
> > recommendation would be to look at some introductory material for
> > Visual Basic 6.0, as this will give you both the working basics of the
> > language, and also basics of programming. Another good choice would
> > be Excel 200x VBA Programmer's Reference or Excel 200x VBA Power
> > Programming, both of which start at the beginning and provide VBA-
> > specific material. Any of these references will also give you a
> > sufficient introduction to how classes work - critical for VBA,
> > because just about everything is a class object or a member of one.
> >
> > Here's an example of a simple spreadsheet application working with
> > Outlook. Column A contains task names; column B contains due dates.
> > Placed inside a worksheet's code module, it processes input in cells
> > B2:B50 (leaving row 1 for headers), and creates an outlook task item.
> > I put comments to help you figure out what's going on. Try it out:
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > ' only using range B2:B50
> > If Not (Intersect(Target, Me.Range("B2:B50")) _
> > Is Nothing) Then
> >
> > ' these are the objects we're working with
> > Dim objOutlook As Object
> > Dim objItem As Object
> > Dim blnOutlookRunning As Boolean
> > Dim dtDueDate As Date
> >
> > ' make sure a date is entered
> > On Error Resume Next
> > dtDueDate = Target.Value
> > On Error GoTo 0
> >
> > ' if a date is not entered,
> > ' alert user and clear input
> > If dtDueDate = 0 Then
> > Call MsgBox("Enter a date!", vbExclamation)
> > Application.EnableEvents = False
> > Target.Clear
> > Application.EnableEvents = True
> > Exit Sub
> > End If
> >
> > ' check to see if outlook is already running
> > On Error Resume Next
> > Set objOutlook = GetObject(, _
> > "Outlook.Application")
> > blnOutlookRunning = True
> > On Error GoTo 0
> >
> > ' if outlook is not running, start it
> > If objOutlook Is Nothing Then
> > blnOutlookRunning = False
> > Set objOutlook = _
> > CreateObject("Outlook.Application")
> > End If
> >
> > ' create a new item
> > Set objItem = _
> > objOutlook.CreateItem(olTaskItem)
> >
> > ' set item properties based on spreadsheet
> > With objItem
> > .DueDate = dtDueDate
> > .Subject = "Get " & Target.Offset(0, -1).Value _
> > & " done by " & Target.Value
> > .Save
> > End With
> >
> > ' quit outlook if it wasn't running
> > If Not blnOutlookRunning Then
> > objOutlook.Quit
> > End If
> > End If
> > End Sub
> >
> > On Nov 7, 10:52 am, sue2uk <sue...@discussions.microsoft.com> wrote:
> >
> >
> >
> > > This was my original question on the Excel discussion group:
> > > "I have a couple of rental properties abroad and have a simple Excel
> > > spreadsheet with details of the booking, client, deposit paid, date balance
> > > due etc. Is there any way that this can be linked to Outlook as a task or in
> > > the calendar to alert me on the due date to remind me to chase the client for
> > > payment of their balance?"
> > > It was suggested that I look for a VBA solution - is this something I can do
> > > myself, learn quickly, where do I start, any suggestions? (I did some
> > > programming briefly about 20 years ago!!!!)- Hide quoted text -

> >
> > - Show quoted text -

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to learn it all... quickly! ziploc_chik Microsoft Excel New Users 22 25th Jul 2008 05:37 PM
How to learn Access VBA / How did you learn VBA? Choli Microsoft Access VBA Modules 1 13th Apr 2008 01:28 AM
how to quickly check for database connectivity quickly =?Utf-8?B?Qmx1ZW1lbA==?= Microsoft ADO .NET 1 17th Oct 2006 11:44 AM
Re: OT: PowerPoint?? Best Book to Learn Quickly?? maxfoo Microsoft Powerpoint 1 28th Mar 2004 02:58 PM
Re: Quickly learn C# Morten Wennevik Microsoft C# .NET 0 18th Feb 2004 11:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:56 PM.