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 / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Run-time error 1004

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ISA - 25 Jan 2006 20:20 GMT
I use a macro to save an XLS workbook (created from an XLT template) to HTML
format for our intranet. It works fine once, but the second time it opens the
saved HTML file before running the macro, which causes the error:
Run-time error '1004': You cannot save this workbook with the same name as
another open workbook or add-in....
I am running the macro from a new toolbar.

How do I prevent the macro from opening the HTML file?

Sub PostNEXTMonth()
' MoveToCalendarWorksheet
   ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
   Sheets("CALENDAR").Select
'save to folder
'    ActiveWorkbook.Save
' publish worksheet to Intranet
   Application.DisplayAlerts = False
   ActiveWorkbook.SaveAs Filename:="\\intranet\OnCallDocs\OnCall-next.htm", _
       FileFormat:=xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False
   Application.DisplayAlerts = True
'close without saving
     ActiveWorkbook.Close saveChanges:=False
      ThisWorkbook.Saved = True
'close Excel
Application.Quit
End Sub
ISA - 25 Jan 2006 22:29 GMT
Never mind. I added the macro to a text box in the template file, added code
to delete the box before saving it to HTML, and it works every time now
without any errors.

> I use a macro to save an XLS workbook (created from an XLT template) to HTML
> format for our intranet. It works fine once, but the second time it opens the
[quoted text clipped - 22 lines]
> Application.Quit
> 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.