Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SaveAs Doesn't Work!

Status
Not open for further replies.

gloudo

Programmer
Feb 3, 2002
34
NL
Hi There,

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 <> &quot;False&quot; Then
GoSub Exit_okbtn_Click

ElseIf sFileName <> &quot;True&quot; Then
GoSub Mail
End If

Mail:

With objMail
.To = Form1.sReciptxt.Text
.CC = &quot;Hans Zwennes&quot;
.Subject = &quot;Probleemhoek Formulier&quot; & &quot; &quot; & Date
.Body = &quot;Dit Is een Test&quot;
.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
 
Yet Another Question.

Is There A Way To Check if Outlook is opened?
If Not then, Open It after The Check

Thanks,
 
Did you check that the file did not get created?

Here is a problem that I have found. After the SaveAs the new file is still opened and some applications, being afraid of getting a dirty copy of a file, will fail to open the file. The error message may be inaccrate about the reason for failure.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top