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 / General MS InfoPath Questions / March 2006

Tip: Looking for answers? Try searching our database.

Infopath and programming with VBS. Help me please....

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
obirch - 15 Mar 2006 15:45 GMT
I have the following code, which I try to place in a Button Control under
Edit Form Code. The form is set to VBS coding.
When I try to use Preview Form, i get the error

"InfoPath cannot open the selected form because of an error in the form's
code.
The following error occurred:

Expected end of statement
File:script.vbs
Line:22
Dim bStarted As Boolean"

I don't understand why I get this error, could some one help me please?

The code...........
-------------------------------------------------------------------------------
Sub CTRL1_5_OnClick(eventObj)
' Write your code here

Dim bStarted As Boolean                '<<== This is where I get the error
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
   MsgBox "Document needs to be saved first"
   Exit Sub
End If

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
   Set oOutlookApp = CreateObject("Outlook.Application")
   bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
    'Set the recipient
   .To = "oxhb@manbw.dk"
   'Set the recipient for a copy
   '.CC = "recipient2@mail.com"
   'Set the subject
   .Subject = "New subject"
   'The content of the document is used as the body for the email
   .Body = "Info"
   'Add the document as an attachment, you can use the .displayname property
   'to set the description that's used in the message
   '.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
   '  DisplayName:="Document as attachment"
   .Send
End With

If bStarted Then
   oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
S.Y.M. Wong-A-Ton - 15 Mar 2006 16:05 GMT
Remove all the "As..." declarations. VBScript does not know typed data. So
instead of

Dim bStarted As Boolean          

use

Dim bStarted

Do the same for all the other variable declarations.
---
S.Y.M. Wong-A-Ton

> I have the following code, which I try to place in a Button Control under
> Edit Form Code. The form is set to VBS coding.
[quoted text clipped - 59 lines]
>
> End Sub
 
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.