Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Isa Isa is offline
external usenet poster
 
Posts: 16
Default Run-time error 1004

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
Isa Isa is offline
external usenet poster
 
Posts: 16
Default Run-time error 1004

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.


"ISA" wrote:

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

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
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


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

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

About Us

"It's about Microsoft Excel"