Hi There,
I Have two Questions.
First:
I Have Made A Script That Firstly Shows the dialogbox SaveAs and Secondly Sends the File With Outlook.
The Problem Is When In The SaveAs DialogBox Save Is Pressed
The File Isn't Saved, Witch results in: Error Can't Find File.
Here Is My Code.
Private Sub okbtn_Click()
On Error GoTo Err_okbtn_Click
Dim sFileName As String
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
sFileName = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel-Werkmap(*.xls), *.xls"
If sFileName <> "False" Then
GoSub Exit_okbtn_Click
ElseIf sFileName <> "True" Then
GoSub Mail
End If
Mail:
With objMail
.To = Form1.sReciptxt.Text
.CC = "Hans Zwennes"
.Subject = "Probleemhoek Formulier" & " " & Date
.Body = "Dit Is een Test"
.Display
.Attachments.Add sFileName
End With
Exit_okbtn_Click:
Set objMail = Nothing
Set objOL = Nothing
Unload Form1
Exit Sub
Err_okbtn_Click:
MsgBox Err.Description
Resume Exit_okbtn_Click
End Sub
Second:
Is There A Way To Check if Outlook is opened from Excel?
If Not then, Open It after The Check.
The Problem Is That the Form Has to work on the company network, Where Outlook is opened by some central program-lancher.
Thanks,
I Have two Questions.
First:
I Have Made A Script That Firstly Shows the dialogbox SaveAs and Secondly Sends the File With Outlook.
The Problem Is When In The SaveAs DialogBox Save Is Pressed
The File Isn't Saved, Witch results in: Error Can't Find File.
Here Is My Code.
Private Sub okbtn_Click()
On Error GoTo Err_okbtn_Click
Dim sFileName As String
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
sFileName = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel-Werkmap(*.xls), *.xls"
If sFileName <> "False" Then
GoSub Exit_okbtn_Click
ElseIf sFileName <> "True" Then
GoSub Mail
End If
Mail:
With objMail
.To = Form1.sReciptxt.Text
.CC = "Hans Zwennes"
.Subject = "Probleemhoek Formulier" & " " & Date
.Body = "Dit Is een Test"
.Display
.Attachments.Add sFileName
End With
Exit_okbtn_Click:
Set objMail = Nothing
Set objOL = Nothing
Unload Form1
Exit Sub
Err_okbtn_Click:
MsgBox Err.Description
Resume Exit_okbtn_Click
End Sub
Second:
Is There A Way To Check if Outlook is opened from Excel?
If Not then, Open It after The Check.
The Problem Is That the Form Has to work on the company network, Where Outlook is opened by some central program-lancher.
Thanks,