PC Review


Reply
Thread Tools Rate Thread

Command Button- Open Word Doc

 
 
Stephen Baer
Guest
Posts: n/a
 
      1st Jan 2009
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!
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      1st Jan 2009
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 (E-Mail Removed)> wrote in message
news:159AD3E5-B6D9-43D0-B3F5-(E-Mail Removed)...
> 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!


 
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
Can I use a Command Button to open a word file =?Utf-8?B?Q29tYm8gYm94IGFuZCBRdWVyaWVz?= Microsoft Access Forms 2 27th Sep 2005 08:17 PM
Open a Word Document from a command Button =?Utf-8?B?U2xvdyBMZWFybmVy?= Microsoft Access VBA Modules 1 25th Nov 2004 12:43 AM
Need command button to open word document Scott Microsoft Access Forms 1 13th Oct 2004 06:56 AM
Command Button To Open Specific Word Doc pas926 Microsoft Access Form Coding 1 9th Sep 2003 08:11 AM
Open a file in word using a command button Paul Microsoft Access Forms 3 1st Sep 2003 09:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 PM.