Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JP JP is offline
external usenet poster
 
Posts: 103
Default "Document not saved" error after typing a line of code in Excel VB

I'm working with an Excel 2003 workbook that has lots of code in Visual
Basic. I am logged into a server domain at work, and the workbook is saved
on a share drive that only I have access to. The workbook is not shared or
password protected.

After entering some code, I tried to save the workbook and Excel gave me the
following 3 error prompts:
1st error message: "Your changes could not be saved to 'workbookname.xls'
because of a sharing violation. Try saving to a different file."

2nd message: "[Drive]:\[Folder]\23d7200.xls count no be found. Check the
spelling og the file name, and verify the file location is correct."

3rd message: Your changes could no be saved to 'workbook name.xls', but were
saved to a temporary document named '23d7200'. Close the existing document,
then open the temporary document and save it under a new name."

After the messages, attempting to save the document again failed; I got the
message "Document not saved."

I re-opened and re-entered my code line-by-line, saving after each
successfully until I entered the line: "Dim myAttachments As
Outlook.Attachments" (See the full code below). The code is simple: loop
through the elements of an array of file names, and add the path to an email
as an attachment. I can't figure out why on this specific line Excel stops
allowing me save.

Can someone please help!!!

Code:

Sub DisplayEmail(attachmentlist As Variant)
Dim myolApp As Outlook.Application
Set myolApp = GetObject(, "Outlook.Application")

Dim myMail As Outlook.MailItem
Set myMail = myolApp.CreateItem(olMailItem)

Dim myAttachments As Outlook.Attachments ' HERES THE CULPRIT
Set myAttachments = myMail.Attachments

For i = 0 To UBound(attachmentlist)
myAttachments.Add attachmentlist(i)
Next i

With myMail
.To = "
.Body = "Attachment test"
.Display
End With

set myAttachments = Nothing
Set myMail = Nothing
Set myolApp = Nothing
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Document Not Saved" Saving File Created from Template PLEASEHELP!!!! Pamela[_3_] Excel Discussion (Misc queries) 1 February 5th 09 07:42 AM
"Document not saved" "error in loading DLL" Tracey L Excel Discussion (Misc queries) 0 December 1st 08 12:57 PM
Excel "Document not saved" error jcf Excel Discussion (Misc queries) 3 April 16th 08 12:10 PM
Typing "..." gives me a verticle line. how do i disable this? Dave Close Excel Discussion (Misc queries) 1 August 29th 07 12:44 PM
Solution "Your changes could not be saved" "The document may be read-only or encrypted" [email protected] Excel Discussion (Misc queries) 0 August 7th 06 06:31 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"