A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Command Button- Open Word Doc



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 1st 09, 04:35 PM posted to microsoft.public.outlook.program_forms
Stephen Baer
external usenet poster
 
Posts: 2
Default Command Button- Open Word Doc

Hi, I'm pretty good at VBA, but I'm experiencing something new. I'm designing
an Outlook form on our Terminal Server. I was getting ready to insert some
code for a command button, similar to the thread "XLsheet Button Control to
Lauch form the Public Drive" in this forum. I'll be openinging a Word Doc
instead, but when I went to view the code, I got "Microsoft Script Editor, "
instead of the vba code interface. How does this work? Does it use the same
basic format? I also am worried that the Outlook "Use Word as the email
editor" option might give me problems, since Word will be open already. Here
is the rough draft of the code I was thinking of using. Any help would be
appreciated!

Private Sub cmdHandbook_Click
Dim WApp as Word.Application
Dim stFilename, stPath as String
stPth = "P:\Public Documents\Staff\New Hire\"
stFilename = "Employee Handbook.doc"
Set WApp = New Word.Application
With WApp
.Documents.Open(FileName: stpath & stFilename, ReadOnly:=True)
.Visible=true
End With
End Sub
Unfortunately, this doesn't work. When I "run this form" I get a popup
"Expected End of Statement: Line No. 2", and yes of course I used the real
path and real doc name
Office 2003, btw.
Thanks in advance!
Ads
  #2  
Old January 1st 09, 07:03 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Command Button- Open Word Doc

All Outlook form code is VBScript code, not VBA code. The line with the
error will work if you comment out the As clause:

Dim WApp 'as Word.Application

No Outlook or Word constants or enum values, you must use the actual value
or declare a constant, etc.

All the limitations of VBS as opposed to VBA code.

See the forms pages at www.outlookcode.com for lots more information about
the quirks of designing and using Outlook forms.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stephen Baer" Stephen wrote in message
...
Hi, I'm pretty good at VBA, but I'm experiencing something new. I'm
designing
an Outlook form on our Terminal Server. I was getting ready to insert
some
code for a command button, similar to the thread "XLsheet Button Control
to
Lauch form the Public Drive" in this forum. I'll be openinging a Word Doc
instead, but when I went to view the code, I got "Microsoft Script Editor,
"
instead of the vba code interface. How does this work? Does it use the
same
basic format? I also am worried that the Outlook "Use Word as the email
editor" option might give me problems, since Word will be open already.
Here
is the rough draft of the code I was thinking of using. Any help would be
appreciated!

Private Sub cmdHandbook_Click
Dim WApp as Word.Application
Dim stFilename, stPath as String
stPth = "P:\Public Documents\Staff\New Hire\"
stFilename = "Employee Handbook.doc"
Set WApp = New Word.Application
With WApp
.Documents.Open(FileName: stpath & stFilename, ReadOnly:=True)
.Visible=true
End With
End Sub
Unfortunately, this doesn't work. When I "run this form" I get a popup
"Expected End of Statement: Line No. 2", and yes of course I used the real
path and real doc name
Office 2003, btw.
Thanks in advance!


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Button [email protected] Outlook - Using Forms 12 January 18th 08 06:57 PM
Open File from Command Button taborp Outlook - Using Forms 10 October 15th 07 06:32 AM
Command Button Daniel Vargas Outlook - Using Forms 1 May 23rd 07 10:35 PM
command button and multipage snwooz Outlook - Using Forms 1 November 1st 06 08:26 PM
Command buttons when using word as email button [email protected] Add-ins for Outlook 1 October 9th 06 10:27 PM


All times are GMT +1. The time now is 06:55 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-2025 Outlook Banter.
The comments are property of their posters.