Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Which is the error in this VBS

Reply
 
Old 03-05-2009   #1 (permalink)
Javier VFM


 
 

Which is the error in this VBS

I have the following routine to add date to the subject, but alone of the
marked the first messages, someone can say to me in that I am wrong

Thank

Sub añado_fecha_asunto()

Dim ol As Object
Dim olns As Object
Dim dia, mes
Dim strfecha As String
Dim asuntofecha As String

Dim i As Integer

If Day(Date) < 10 Then
dia = "0" & Day(Date)
End If

If Day(Date) >= 10 Then
dia = Day(Date)
End If

' añado un 0 si el mes tiene un digito

If Month(Date) < 10 Then
mes = "0" & Month(Date)
End If

If Month(Date) >= 10 Then
mes = Month(Date)
End If

' Pongo variable strfecha a la cabecera necesaria

strfecha = ("09" & " - " & mes & " - " & dia & " ")


Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set myFolder = ol.ActiveExplorer.CurrentFolder

numitems = ol.ActiveExplorer.Selection.Count

For i = 1 To numitems


' MsgBox ol.ActiveExplorer.Selection.Item(i).Subject


asuntofecha = strfecha &
ol.ActiveExplorer.Selection.Item(i).Subject

MsgBox asuntofecha

ol.ActiveExplorer.Selection.Item(i).Subject = asuntofecha


Next i





End Sub


My System SpecsSystem Spec
Old 03-05-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Which is the error in this VBS


"Javier VFM" <JavierVFM@xxxxxx> wrote in message
news:67FAA8AC-827A-4DAE-A24F-2A3515FFE2BF@xxxxxx
Quote:

>I have the following routine to add date to the subject, but alone of the
> marked the first messages, someone can say to me in that I am wrong
>
> Thank
>
> Sub añado_fecha_asunto()
>
> Dim ol As Object
> Dim olns As Object
> Dim dia, mes
> Dim strfecha As String
> Dim asuntofecha As String
>
> Dim i As Integer
>
> If Day(Date) < 10 Then
> dia = "0" & Day(Date)
> End If
>
> If Day(Date) >= 10 Then
> dia = Day(Date)
> End If
>
> ' añado un 0 si el mes tiene un digito
>
> If Month(Date) < 10 Then
> mes = "0" & Month(Date)
> End If
>
> If Month(Date) >= 10 Then
> mes = Month(Date)
> End If
>
> ' Pongo variable strfecha a la cabecera necesaria
>
> strfecha = ("09" & " - " & mes & " - " & dia & " ")
>
>
> Set ol = New Outlook.Application
> Set olns = ol.GetNamespace("MAPI")
> Set myFolder = ol.ActiveExplorer.CurrentFolder
>
> numitems = ol.ActiveExplorer.Selection.Count
>
> For i = 1 To numitems
>
>
> ' MsgBox ol.ActiveExplorer.Selection.Item(i).Subject
>
>
> asuntofecha = strfecha &
> ol.ActiveExplorer.Selection.Item(i).Subject
>
> MsgBox asuntofecha
>
> ol.ActiveExplorer.Selection.Item(i).Subject = asuntofecha
>
>
> Next i
>
>
>
>
>
> End Sub
>
The code is classic VB rather than VBScript. You cannot type variables in
VBScript. None of the Dim statements should have the "AS" keyword. When
objects are created, use either CreateObject or GetObject methods in
VBScript.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 03-05-2009   #3 (permalink)
Javier VFM


 
 

Re: Which is the error in this VBS

I am sorry but is a Vba proyect and is a macro in the VB outlook.

is correct or no

"Richard Mueller [MVP]" wrote:
Quote:

>
> "Javier VFM" <JavierVFM@xxxxxx> wrote in message
> news:67FAA8AC-827A-4DAE-A24F-2A3515FFE2BF@xxxxxx
Quote:

> >I have the following routine to add date to the subject, but alone of the
> > marked the first messages, someone can say to me in that I am wrong
> >
> > Thank
> >
> > Sub añado_fecha_asunto()
> >
> > Dim ol As Object
> > Dim olns As Object
> > Dim dia, mes
> > Dim strfecha As String
> > Dim asuntofecha As String
> >
> > Dim i As Integer
> >
> > If Day(Date) < 10 Then
> > dia = "0" & Day(Date)
> > End If
> >
> > If Day(Date) >= 10 Then
> > dia = Day(Date)
> > End If
> >
> > ' añado un 0 si el mes tiene un digito
> >
> > If Month(Date) < 10 Then
> > mes = "0" & Month(Date)
> > End If
> >
> > If Month(Date) >= 10 Then
> > mes = Month(Date)
> > End If
> >
> > ' Pongo variable strfecha a la cabecera necesaria
> >
> > strfecha = ("09" & " - " & mes & " - " & dia & " ")
> >
> >
> > Set ol = New Outlook.Application
> > Set olns = ol.GetNamespace("MAPI")
> > Set myFolder = ol.ActiveExplorer.CurrentFolder
> >
> > numitems = ol.ActiveExplorer.Selection.Count
> >
> > For i = 1 To numitems
> >
> >
> > ' MsgBox ol.ActiveExplorer.Selection.Item(i).Subject
> >
> >
> > asuntofecha = strfecha &
> > ol.ActiveExplorer.Selection.Item(i).Subject
> >
> > MsgBox asuntofecha
> >
> > ol.ActiveExplorer.Selection.Item(i).Subject = asuntofecha
> >
> >
> > Next i
> >
> >
> >
> >
> >
> > End Sub
> >
>
> The code is classic VB rather than VBScript. You cannot type variables in
> VBScript. None of the Dim statements should have the "AS" keyword. When
> objects are created, use either CreateObject or GetObject methods in
> VBScript.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>
My System SpecsSystem Spec
Old 03-05-2009   #4 (permalink)
Joe Fawcett


 
 

Re: Which is the error in this VBS

In that case you need a VB forum. VB and VBScript are two different beasts.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"Javier VFM" <JavierVFM@xxxxxx> wrote in message
news:7CD71BA5-2043-40A3-B9DE-AD0B13A3CDB8@xxxxxx
Quote:

> I am sorry but is a Vba proyect and is a macro in the VB outlook.
>
> is correct or no
>
> "Richard Mueller [MVP]" wrote:
>
Quote:

>>
>> "Javier VFM" <JavierVFM@xxxxxx> wrote in message
>> news:67FAA8AC-827A-4DAE-A24F-2A3515FFE2BF@xxxxxx
Quote:

>> >I have the following routine to add date to the subject, but alone of
>> >the
>> > marked the first messages, someone can say to me in that I am wrong
>> >
>> > Thank
>> >
>> > Sub añado_fecha_asunto()
>> >
>> > Dim ol As Object
>> > Dim olns As Object
>> > Dim dia, mes
>> > Dim strfecha As String
>> > Dim asuntofecha As String
>> >
>> > Dim i As Integer
>> >
>> > If Day(Date) < 10 Then
>> > dia = "0" & Day(Date)
>> > End If
>> >
>> > If Day(Date) >= 10 Then
>> > dia = Day(Date)
>> > End If
>> >
>> > ' añado un 0 si el mes tiene un digito
>> >
>> > If Month(Date) < 10 Then
>> > mes = "0" & Month(Date)
>> > End If
>> >
>> > If Month(Date) >= 10 Then
>> > mes = Month(Date)
>> > End If
>> >
>> > ' Pongo variable strfecha a la cabecera necesaria
>> >
>> > strfecha = ("09" & " - " & mes & " - " & dia & " ")
>> >
>> >
>> > Set ol = New Outlook.Application
>> > Set olns = ol.GetNamespace("MAPI")
>> > Set myFolder = ol.ActiveExplorer.CurrentFolder
>> >
>> > numitems = ol.ActiveExplorer.Selection.Count
>> >
>> > For i = 1 To numitems
>> >
>> >
>> > ' MsgBox ol.ActiveExplorer.Selection.Item(i).Subject
>> >
>> >
>> > asuntofecha = strfecha &
>> > ol.ActiveExplorer.Selection.Item(i).Subject
>> >
>> > MsgBox asuntofecha
>> >
>> > ol.ActiveExplorer.Selection.Item(i).Subject = asuntofecha
>> >
>> >
>> > Next i
>> >
>> >
>> >
>> >
>> >
>> > End Sub
>> >
>>
>> The code is classic VB rather than VBScript. You cannot type variables in
>> VBScript. None of the Dim statements should have the "AS" keyword. When
>> objects are created, use either CreateObject or GetObject methods in
>> VBScript.
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>>
>>


My System SpecsSystem Spec
Old 03-05-2009   #5 (permalink)
Auric__


 
 

Re: Which is the error in this VBS

On Thu, 05 Mar 2009 10:41:01 GMT, JavierVFM wrote:
Quote:

> I have the following routine to add date to the subject, but alone of the
> marked the first messages, someone can say to me in that I am wrong
[snip]
Quote:

> Dim dia, mes
I would declare these both as strings:
Dim dia As String, mes As String
Quote:

> End If
> If Day(Date) >= 10 Then
Replace the above two lines with "Else".
Quote:

> End If
> If Month(Date) >= 10 Then
Replace the above two lines with "Else".

My suggestions won't solve your problem, whatever it is. (I don't know
anything about Outlook. Your code looks okay to me.) I would ask this
question in this group:
microsoft.public.office.developer.outlook.vba

--
auric dot auric at gmail dot com
--
Starting today, all passwords must contain letters,
numbers, doodles, sign language, and squirrel noises.
My System SpecsSystem Spec
Old 03-05-2009   #6 (permalink)
Al Dunbar


 
 

Re: Which is the error in this VBS

or perhaps a VBA forum, as vb, vbscript, and vba are three different beasts.

/Al

"Joe Fawcett" <joefawcett@xxxxxx> wrote in message
news:uvnuxlbnJHA.5412@xxxxxx
Quote:

> In that case you need a VB forum. VB and VBScript are two different
> beasts.
>
> --
>
> Joe Fawcett (MVP - XML)
> http://joe.fawcett.name
> "Javier VFM" <JavierVFM@xxxxxx> wrote in message
> news:7CD71BA5-2043-40A3-B9DE-AD0B13A3CDB8@xxxxxx
Quote:

>> I am sorry but is a Vba proyect and is a macro in the VB outlook.
>>
>> is correct or no
>>
>> "Richard Mueller [MVP]" wrote:
>>
Quote:

>>>
>>> "Javier VFM" <JavierVFM@xxxxxx> wrote in message
>>> news:67FAA8AC-827A-4DAE-A24F-2A3515FFE2BF@xxxxxx
>>> >I have the following routine to add date to the subject, but alone of
>>> >the
>>> > marked the first messages, someone can say to me in that I am wrong
>>> >
>>> > Thank
>>> >
>>> > Sub añado_fecha_asunto()
>>> >
>>> > Dim ol As Object
>>> > Dim olns As Object
>>> > Dim dia, mes
>>> > Dim strfecha As String
>>> > Dim asuntofecha As String
>>> >
>>> > Dim i As Integer
>>> >
>>> > If Day(Date) < 10 Then
>>> > dia = "0" & Day(Date)
>>> > End If
>>> >
>>> > If Day(Date) >= 10 Then
>>> > dia = Day(Date)
>>> > End If
>>> >
>>> > ' añado un 0 si el mes tiene un digito
>>> >
>>> > If Month(Date) < 10 Then
>>> > mes = "0" & Month(Date)
>>> > End If
>>> >
>>> > If Month(Date) >= 10 Then
>>> > mes = Month(Date)
>>> > End If
>>> >
>>> > ' Pongo variable strfecha a la cabecera necesaria
>>> >
>>> > strfecha = ("09" & " - " & mes & " - " & dia & " ")
>>> >
>>> >
>>> > Set ol = New Outlook.Application
>>> > Set olns = ol.GetNamespace("MAPI")
>>> > Set myFolder = ol.ActiveExplorer.CurrentFolder
>>> >
>>> > numitems = ol.ActiveExplorer.Selection.Count
>>> >
>>> > For i = 1 To numitems
>>> >
>>> >
>>> > ' MsgBox ol.ActiveExplorer.Selection.Item(i).Subject
>>> >
>>> >
>>> > asuntofecha = strfecha &
>>> > ol.ActiveExplorer.Selection.Item(i).Subject
>>> >
>>> > MsgBox asuntofecha
>>> >
>>> > ol.ActiveExplorer.Selection.Item(i).Subject = asuntofecha
>>> >
>>> >
>>> > Next i
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > End Sub
>>> >
>>>
>>> The code is classic VB rather than VBScript. You cannot type variables
>>> in
>>> VBScript. None of the Dim statements should have the "AS" keyword. When
>>> objects are created, use either CreateObject or GetObject methods in
>>> VBScript.
>>>
>>> --
>>> Richard Mueller
>>> MVP Directory Services
>>> Hilltop Lab - http://www.rlmueller.net
>>> --
>>>
>>>
>>>
>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Help with windows vista mail, Socket Error: 10053, Error Number: 0x800CCC0F Vista mail
no,socket Error: 11003. Error Number: 0x800CC0D cant i send email name is correctly Vista mail
Canot post to newsgroups Socket Error: 10053, Error Number: 0x800CCC0F Vista mail
Canot post to newsgroups Socket Error: 10053, Error Number: 0x800CCC0F Vista General
windows live mail 2008 (Build 12.0.1606) error report error Windows Live


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46