Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   installing VB script (http://www.outlookbanter.com/outlook-vba/8918-installing-vb-script.html)

windandwaves March 20th 06 11:10 PM

installing VB script
 
Sue Mosher [MVP-Outlook] wrote:
Copy and paste it into a Notepad text file and email that file to him
along with instructions for how to copy and paste the code into a
module in the Outlook VBA environment.


Hey Sue,
thank you for your reply. much appreciated. is there anything more
sophisticated then the method you outline above? my client is a novice,
novice and I would prefer a simple installer as it would look more
professional.

TIA

Nicolaas


PS my next question is how I can create a button in outlook that calls the
code.


FYI, there is a newsgroup specifically for general Outlook
programming issues "down the hall" at
microsoft.public.outlook.program_vba or, via web interface, at
http://www.microsoft.com/office/comm....program_v ba


"windandwaves" wrote in message
...
Hi Gurus

I have written a piece of VB script (see below). I want to send
this to a client so that he can install it. My question is, how can
I send that best. I know they have access so should i put it in
access and then export from there into outlook?

Any help greatly appreciated (this is all new to me)

Nicolaas




Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties.
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)

With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = go()
.Display
End With
End Sub



Function go()
Dim Fs
Dim A
Dim PathandFile As String
'-
PathandFile = "c:\testfile.htm"
Set Fs = CreateObject("Scripting.FileSystemObject")
Set A = Fs.OpenTextFile(PathandFile)
'read rest of the file
Do While A.AtEndOfStream True
ReadFile = ReadFile & Trim(A.ReadLine)
Loop
A.Close
'-check last line
go = strtext
End Function




Sue Mosher [MVP-Outlook] March 20th 06 11:17 PM

installing VB script
 
There is no programmatic way to install VBA code. Maybe you should be building them a COM addin instead? Or take out the variable data typing so you can redo it as a VBSCript .vbs file.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"windandwaves" wrote in message ...
Sue Mosher [MVP-Outlook] wrote:
Copy and paste it into a Notepad text file and email that file to him
along with instructions for how to copy and paste the code into a
module in the Outlook VBA environment.


Hey Sue,
thank you for your reply. much appreciated. is there anything more
sophisticated then the method you outline above? my client is a novice,
novice and I would prefer a simple installer as it would look more
professional.

TIA

Nicolaas


PS my next question is how I can create a button in outlook that calls the
code.


FYI, there is a newsgroup specifically for general Outlook
programming issues "down the hall" at
microsoft.public.outlook.program_vba or, via web interface, at
http://www.microsoft.com/office/comm....program_v ba


"windandwaves" wrote in message
...
Hi Gurus

I have written a piece of VB script (see below). I want to send
this to a client so that he can install it. My question is, how can
I send that best. I know they have access so should i put it in
access and then export from there into outlook?

Any help greatly appreciated (this is all new to me)

Nicolaas



Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties.
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)

With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = go()
.Display
End With
End Sub



Function go()
Dim Fs
Dim A
Dim PathandFile As String
'-
PathandFile = "c:\testfile.htm"
Set Fs = CreateObject("Scripting.FileSystemObject")
Set A = Fs.OpenTextFile(PathandFile)
'read rest of the file
Do While A.AtEndOfStream True
ReadFile = ReadFile & Trim(A.ReadLine)
Loop
A.Close
'-check last line
go = strtext
End Function




windandwaves March 21st 06 12:39 AM

installing VB script
 
Sue Mosher [MVP-Outlook] wrote:
There is no programmatic way to install VBA code. Maybe you should be
building them a COM addin instead? Or take out the variable data
typing so you can redo it as a VBSCript .vbs file.


What would you recommend. I checked out Com Addin and I need all sorts of
software for that I believe. VBscript may be a better option. Do you know
any good places where I can find help for this.

Thanks again.

Nicolaas




Sue Mosher [MVP-Outlook] March 21st 06 05:53 AM

installing VB script
 
This newsgroup covers VBScript applications of Outlook programming techniques, as well as VBA. Basically, all you need to do is:

-- remove the data typing from variable and procedure declarations
-- declare any Outlook constants or use the literal values
-- instantiate an Outlook.Application object with CreateObject()

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"windandwaves" wrote in message ...
Sue Mosher [MVP-Outlook] wrote:
There is no programmatic way to install VBA code. Maybe you should be
building them a COM addin instead? Or take out the variable data
typing so you can redo it as a VBSCript .vbs file.


What would you recommend. I checked out Com Addin and I need all sorts of
software for that I believe. VBscript may be a better option. Do you know
any good places where I can find help for this.

Thanks again.

Nicolaas




windandwaves March 21st 06 10:07 PM

installing VB script
 
Sue Mosher [MVP-Outlook] wrote:
This newsgroup covers VBScript applications of Outlook programming
techniques, as well as VBA. Basically, all you need to do is:

-- remove the data typing from variable and procedure declarations
-- declare any Outlook constants or use the literal values
-- instantiate an Outlook.Application object with CreateObject()


"windandwaves" wrote in message
...
Sue Mosher [MVP-Outlook] wrote:
There is no programmatic way to install VBA code. Maybe you should
be building them a COM addin instead? Or take out the variable data
typing so you can redo it as a VBSCript .vbs file.


What would you recommend. I checked out Com Addin and I need all
sorts of software for that I believe. VBscript may be a better
option. Do you know any good places where I can find help for this.

Thanks again.

Nicolaas



Here is the VB script that I created, it works a treat in XP. Any further
comments greatly appreciated.

Dim theApp
Set theApp = WScript.CreateObject("Outlook.Application")
CreateHTMLMail(theApp)
Public Sub CreateHTMLMail(olapp)
'Creates a new e-mail item and modifies its properties.
'Dim olApp As Outlook.Application
Dim objMail 'As Outlook.MailItem
'Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
..BodyFormat = 2' olFormatHTML
..HTMLBody = gettemplate("")
..Display
End With
End Sub


Private Function gettemplate(PathandFile)
Dim Fs
Dim A
Dim Readfile 'As String
'-
if PathandFile "" then
Set Fs = CreateObject("Scripting.FileSystemObject")
Set A = Fs.OpenTextFile(PathandFile)
'read rest of the file
Do While A.AtEndOfStream True
Readfile = Readfile & Trim(A.ReadLine)
Loop
A.Close
'-check last line
else
readfile = "htmlheadtitletest/titlebody style=" & chr(34) & "
background-color: red;" & chr(34)& "off you go/bodyhtml"
end if
gettemplate = Readfile
End Function


Is there a way to have an html document embedded in this document without
having to be so clumsy with all the " & chr(34)& "??? I would love to have
a way to include a text-block in the script.

TIA

Nicolaas




Sue Mosher [MVP-Outlook] March 21st 06 11:53 PM

installing VB script
 
An alternative to putting in Chr(34) is to use a function:

Function Quote(text)
Quote = Chr(34) & text & Chr(34)
End Function

and thus

readfile = "htmlheadtitletest/titlebody style=" & _
Quote("background-color: red;") & "off you go/bodyhtml"

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"windandwaves" wrote in message ...
Sue Mosher [MVP-Outlook] wrote:
This newsgroup covers VBScript applications of Outlook programming
techniques, as well as VBA. Basically, all you need to do is:

-- remove the data typing from variable and procedure declarations
-- declare any Outlook constants or use the literal values
-- instantiate an Outlook.Application object with CreateObject()


"windandwaves" wrote in message
...
Sue Mosher [MVP-Outlook] wrote:
There is no programmatic way to install VBA code. Maybe you should
be building them a COM addin instead? Or take out the variable data
typing so you can redo it as a VBSCript .vbs file.

What would you recommend. I checked out Com Addin and I need all
sorts of software for that I believe. VBscript may be a better
option. Do you know any good places where I can find help for this.

Thanks again.

Nicolaas



Here is the VB script that I created, it works a treat in XP. Any further
comments greatly appreciated.

Dim theApp
Set theApp = WScript.CreateObject("Outlook.Application")
CreateHTMLMail(theApp)
Public Sub CreateHTMLMail(olapp)
'Creates a new e-mail item and modifies its properties.
'Dim olApp As Outlook.Application
Dim objMail 'As Outlook.MailItem
'Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = 2' olFormatHTML
.HTMLBody = gettemplate("")
.Display
End With
End Sub


Private Function gettemplate(PathandFile)
Dim Fs
Dim A
Dim Readfile 'As String
'-
if PathandFile "" then
Set Fs = CreateObject("Scripting.FileSystemObject")
Set A = Fs.OpenTextFile(PathandFile)
'read rest of the file
Do While A.AtEndOfStream True
Readfile = Readfile & Trim(A.ReadLine)
Loop
A.Close
'-check last line
else
readfile = "htmlheadtitletest/titlebody style=" & chr(34) & "
background-color: red;" & chr(34)& "off you go/bodyhtml"
end if
gettemplate = Readfile
End Function


Is there a way to have an html document embedded in this document without
having to be so clumsy with all the " & chr(34)& "??? I would love to have
a way to include a text-block in the script.

TIA

Nicolaas




windandwaves March 22nd 06 06:14 AM

installing VB script
 
Sue Mosher [MVP-Outlook] wrote:
[snip]...[snip]...[snip]

Thank you for all your help Sue, much appreciated. Awesome! I am stoked
with the results.

Nicolaas





All times are GMT +1. The time now is 08:31 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com