Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / New Users / March 2006

Tip: Looking for answers? Try searching our database.

installing VB script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
windandwaves - 20 Mar 2006 22:34 GMT
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] - 20 Mar 2006 22:58 GMT
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.

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/community/en-us/default.mspx?dg=microsoft.public
.outlook.program_vba


Signature

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
 

> Hi Gurus
>
[quoted text clipped - 39 lines]
> go = strtext
> End Function
windandwaves - 20 Mar 2006 23:10 GMT
> 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
[quoted text clipped - 44 lines]
>> go = strtext
>> End Function
Sue Mosher [MVP-Outlook] - 20 Mar 2006 23:17 GMT
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.

Signature

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
 

>> 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
[quoted text clipped - 61 lines]
>>> go = strtext
>>> End Function
windandwaves - 21 Mar 2006 00:39 GMT
> 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] - 21 Mar 2006 05:53 GMT
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()

Signature

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
 

>> 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
[quoted text clipped - 7 lines]
>
>> Nicolaas
windandwaves - 21 Mar 2006 22:07 GMT
> This newsgroup covers VBScript applications of Outlook programming
> techniques, as well as VBA. Basically, all you need to do is:
[quoted text clipped - 14 lines]
>>
>>> 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 = "<html><head><title>test</title><body style=" & chr(34) & "
background-color: red;" & chr(34)& ">off you go</body><html>"
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] - 21 Mar 2006 23:53 GMT
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 = "<html><head><title>test</title><body style=" & _
            Quote("background-color: red;") & ">off you go</body><html>"

Signature

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
 

>> This newsgroup covers VBScript applications of Outlook programming
>> techniques, as well as VBA. Basically, all you need to do is:
[quoted text clipped - 64 lines]
>
>> Nicolaas
windandwaves - 22 Mar 2006 06:14 GMT
[snip]...[snip]...[snip]

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

> Nicolaas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.