Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AHD AHD is offline
external usenet poster
 
Posts: 1
Default Unexpected error 1004 when using workbooks.open


I have what I thought was a fairly simple macro. This macro runs fine if
I step thru it in debug but gives me an error 1004 if I launch it from a
button from the sheet. Does anybody have any ideas? (I'm running Excel
2003 sp1 on windows XP pro 2002 sp1)

Sub PublishToIntranet()
'
'
'
On Error GoTo Err_Handler_Publish_To_Intranet
Range("A1:Q61").Select
Selection.Copy
ChDir "\\lrfp3\psm\intranetDocuments\dryer\dailyPlan "
workbooks.Open Filename:= _
"\\lrfp3\psm\IntranetDocuments\Dryer\DailyPlan\Dai lyPlan.xls"
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
MsgBox "Page published to Intranet."
Exit Sub
Err_Handler_Publish_To_Intranet:
MsgBox "Unexpected error " & Err.Number & " " & Err.Description &
". Page not published. Please contact CIS", vbOKOnly
End Sub


--
AHD
------------------------------------------------------------------------
AHD's Profile: http://www.excelforum.com/member.php...o&userid=24033
View this thread: http://www.excelforum.com/showthread...hreadid=376445

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Unexpected error 1004 when using workbooks.open

I suspect you need to change the button on the sheet property
TakeFocusOnClick to False

--
Cheers
Nigel



"AHD" wrote in message
...

I have what I thought was a fairly simple macro. This macro runs fine if
I step thru it in debug but gives me an error 1004 if I launch it from a
button from the sheet. Does anybody have any ideas? (I'm running Excel
2003 sp1 on windows XP pro 2002 sp1)

Sub PublishToIntranet()
'
'
'
On Error GoTo Err_Handler_Publish_To_Intranet
Range("A1:Q61").Select
Selection.Copy
ChDir "\\lrfp3\psm\intranetDocuments\dryer\dailyPlan "
workbooks.Open Filename:= _
"\\lrfp3\psm\IntranetDocuments\Dryer\DailyPlan\Dai lyPlan.xls"
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
MsgBox "Page published to Intranet."
Exit Sub
Err_Handler_Publish_To_Intranet:
MsgBox "Unexpected error " & Err.Number & " " & Err.Description &
". Page not published. Please contact CIS", vbOKOnly
End Sub


--
AHD
------------------------------------------------------------------------
AHD's Profile:

http://www.excelforum.com/member.php...o&userid=24033
View this thread: http://www.excelforum.com/showthread...hreadid=376445



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Unexpected error 1004 when using workbooks.open

I think that xl97 bug was fixed in xl2k and the AHD said he(she?) was running
xl2003.




Nigel wrote:

I suspect you need to change the button on the sheet property
TakeFocusOnClick to False

--
Cheers
Nigel

"AHD" wrote in message
...

I have what I thought was a fairly simple macro. This macro runs fine if
I step thru it in debug but gives me an error 1004 if I launch it from a
button from the sheet. Does anybody have any ideas? (I'm running Excel
2003 sp1 on windows XP pro 2002 sp1)

Sub PublishToIntranet()
'
'
'
On Error GoTo Err_Handler_Publish_To_Intranet
Range("A1:Q61").Select
Selection.Copy
ChDir "\\lrfp3\psm\intranetDocuments\dryer\dailyPlan "
workbooks.Open Filename:= _
"\\lrfp3\psm\IntranetDocuments\Dryer\DailyPlan\Dai lyPlan.xls"
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
MsgBox "Page published to Intranet."
Exit Sub
Err_Handler_Publish_To_Intranet:
MsgBox "Unexpected error " & Err.Number & " " & Err.Description &
". Page not published. Please contact CIS", vbOKOnly
End Sub


--
AHD
------------------------------------------------------------------------
AHD's Profile:

http://www.excelforum.com/member.php...o&userid=24033
View this thread: http://www.excelforum.com/showthread...hreadid=376445


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Unexpected error 1004 when using workbooks.open

I'd comment out the "on error..." line and run the code to find out the line
causing the damage.

chdir
won't work for UNC paths, but I'm not sure if it'll blow up either. In any
case, this line can be removed:

ChDir "\\lrfp3\psm\intranetDocuments\dryer\dailyPlan "

=======
There are some things that clear the clipboard. In my simple testing, opening a
workbook left it alone, but maybe that's not always the case (if there's a
workbook_open even that's running).

I'd change the order of a couple of things.

Option Explicit
Sub PublishToIntranet2()

Dim CurWks As Worksheet
Dim newWks As Worksheet
Set CurWks = ActiveSheet

On Error GoTo Err_Handler_Publish_To_Intranet

Workbooks.Open _
Filename:="\\lrfp3\psm\IntranetDocuments\Dryer\Dai lyPlan\DailyPlan.xls"
Set newWks = ActiveSheet

CurWks.Range("a1:q61").Copy
newWks.Range("a1").PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False
newWks.Parent.Close savechanges:=True
MsgBox "Page published to Intranet."

Exit Sub

Err_Handler_Publish_To_Intranet:

MsgBox "Unexpected error " & Err.Number & " " _
& Err.Description & ". Page not published. Please contact CIS", _
vbOKOnly

End Sub



AHD wrote:

I have what I thought was a fairly simple macro. This macro runs fine if
I step thru it in debug but gives me an error 1004 if I launch it from a
button from the sheet. Does anybody have any ideas? (I'm running Excel
2003 sp1 on windows XP pro 2002 sp1)

Sub PublishToIntranet()
'
'
'
On Error GoTo Err_Handler_Publish_To_Intranet
Range("A1:Q61").Select
Selection.Copy
ChDir "\\lrfp3\psm\intranetDocuments\dryer\dailyPlan "
workbooks.Open Filename:= _
"\\lrfp3\psm\IntranetDocuments\Dryer\DailyPlan\Dai lyPlan.xls"
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
MsgBox "Page published to Intranet."
Exit Sub
Err_Handler_Publish_To_Intranet:
MsgBox "Unexpected error " & Err.Number & " " & Err.Description &
". Page not published. Please contact CIS", vbOKOnly
End Sub

--
AHD
------------------------------------------------------------------------
AHD's Profile: http://www.excelforum.com/member.php...o&userid=24033
View this thread: http://www.excelforum.com/showthread...hreadid=376445


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unexpected error 1004 when using workbooks.open


I went with the suggestion of opening the destination excel first and
then bringing focus back to the source book. That seemed to have taken
care of the problem for me. Thank you so much for the help (and yes,
you were helping "her" not "him" :) )
Thanks again!!! Great Forum!!!
Anja


--
AHD
------------------------------------------------------------------------
AHD's Profile: http://www.excelforum.com/member.php...o&userid=24033
View this thread: http://www.excelforum.com/showthread...hreadid=376445



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Unexpected error 1004 when using workbooks.open

Glad you got it working, ma'am! <vbg.

AHD wrote:

I went with the suggestion of opening the destination excel first and
then bringing focus back to the source book. That seemed to have taken
care of the problem for me. Thank you so much for the help (and yes,
you were helping "her" not "him" :) )
Thanks again!!! Great Forum!!!
Anja

--
AHD
------------------------------------------------------------------------
AHD's Profile: http://www.excelforum.com/member.php...o&userid=24033
View this thread: http://www.excelforum.com/showthread...hreadid=376445


--

Dave Peterson
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
workbooks.open and error handling John Keith[_2_] Excel Programming 5 August 18th 05 05:16 PM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
error on oXL.Workbooks.Open arieribbens Excel Programming 3 April 26th 04 10:09 AM
excel workbooks.close returns 1004 error keith Excel Programming 0 September 26th 03 01:05 PM
Error 1004 when I open a file Deer Hunter Excel Programming 3 August 27th 03 05:33 PM


All times are GMT +1. The time now is 06:35 AM.

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"