Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repost with code - Runtime error '1004'

Hi all, (see code below)

Some users are getting the following error.

"Run-time error '1004' Method 'open' of object 'workbooks' failed."

Obviously I'm not sure why. The user has to click on a link that open
the excel sheet. Then they click on a button on the sheet that open
another sheet read only and updates the original sheet. When the butto
is clicked the error is showing up. The files are in the same director
so if the user is able to open the file via the link the user shoul
also be able to open the other file.

This is happening in excel 2000 but the file works fine on my box i
excel 2000.

Any ideas?

Thanks,

Jeff

Private Sub UserForm_Initialize()

Dim wb As Workbook
Application.ScreenUpdating = False ' turn off the screen updating

Set wb = Workbooks.Open("\\sfna-fs4\hrs\shared\CT
Training\ctmTrainingData.xls", True, True)
' open the source workbook, read only
With ThisWorkbook.Worksheets("Training")
' read data from the source workbook
.Range("A1:B13").Formula
wb.Worksheets("Sheet3").Range("A1:B13").Formula
End With
With ThisWorkbook.Worksheets("SignUp")
' read data from the source workbook
.Range("A:B").Formula
wb.Worksheets("SignUp").Range("A:B").Formula
End With

wb.Close False ' close the source workbook without saving an
changes
Set wb = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating

cmbName.Value = ""
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Repost with code - Runtime error '1004'

Hi muziq2,

Some users are getting the following error.

"Run-time error '1004' Method 'open' of object 'workbooks' failed."

Obviously I'm not sure why. The user has to click on a link that opens
the excel sheet. Then they click on a button on the sheet that opens
another sheet read only and updates the original sheet. When the
button is clicked the error is showing up. The files are in the same
directory so if the user is able to open the file via the link the
user should also be able to open the other file.

This is happening in excel 2000 but the file works fine on my box in
excel 2000.


Since the code is being executed via a CommandButton, you should make sure
the TakeFocusOnClick property of the CommandButton is set to False. You can
run into random runtime errors if it's set to True.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repost with code - Runtime error '1004'

Seems that this problem has something to do with how the user accesse
the file.

However, I created the link to the file in an Outlook email that
didn't send and received the run-time error after opening the file an
clicking the CommandButton.

After sending the email to myself and clicking on the link I no longe
get the message.

When I access the file via open or explorer it also works fine.

Below is the link that causes the error.

\\sfna-fs4\hrs\shared\ctm training\ctmtrainingsignup.xls

The following link below does not cause the error.

<\\sfna-fs4\hrs\shared\ctm training\ctmtrainingsignup.xls


Note that with macro security set to medium opening the above link
causes different warning messages.

The first link (the one that produces the run-time error) gives
warning that the file contains macros that may contain harmful viruse
and prompts the user to press yes, no or cancel.

The second also gives a warning that says the file contains viruses bu
prompts the user to either press one of the following buttons: disabl
macros, enable macros, more info.

Any ideas on why the two seperate messages? Or why the one causes th
run-time errors.

Thanks for your response Jake. Whether the takefocusonclick is enable
or disabled there are run-time errors

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Repost with code - Runtime error '1004'

It sounds to me like the first link is attempting to open Excel in Internet
Explorer, as I think that's the macro security prompt you get when opening
an XLS in IE. Spaces in UNC paths can cause issues if you don't use the
brackets like you did in the second example. Is everything working if you
use the <?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Seems that this problem has something to do with how the user accesses
the file.

However, I created the link to the file in an Outlook email that I
didn't send and received the run-time error after opening the file
and clicking the CommandButton.

After sending the email to myself and clicking on the link I no longer
get the message.

When I access the file via open or explorer it also works fine.

Below is the link that causes the error.

\\sfna-fs4\hrs\shared\ctm training\ctmtrainingsignup.xls

The following link below does not cause the error.

<\\sfna-fs4\hrs\shared\ctm training\ctmtrainingsignup.xls


Note that with macro security set to medium opening the above links
causes different warning messages.

The first link (the one that produces the run-time error) gives a
warning that the file contains macros that may contain harmful viruses
and prompts the user to press yes, no or cancel.

The second also gives a warning that says the file contains viruses
but prompts the user to either press one of the following buttons:
disable macros, enable macros, more info.

Any ideas on why the two seperate messages? Or why the one causes the
run-time errors.

Thanks for your response Jake. Whether the takefocusonclick is
enabled or disabled there are run-time errors.


---
Message posted from http://www.ExcelForum.com/


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repost with code - Runtime error '1004'

As far as I know everything works fine when the brackets are used.
Thankfully that's the format that was used when the link was sent to
all users.

Thanks for your help.

Jeff


---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repost with code - Runtime error '1004'

Actually, I just figured out the cause of this problem. Outlook 200
automatically recognizes the link. I do not have to put the brackett
in. The bracketts disappear when the email is opened in it's ow
window. This is when the error occurs.

Everything works fine when the email is viewed in the preview pane.
Not sure why this is.

Definitely a question for the outlook newsgroup.

Thanks,

Jef

--
Message posted from http://www.ExcelForum.com

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
runtime error code 1004 Karen Excel Worksheet Functions 1 May 13th 10 12:21 AM
runtime error '1004' Steve Excel Discussion (Misc queries) 1 April 28th 06 08:58 PM
Runtime Error '1004' [email protected] Excel Discussion (Misc queries) 2 July 18th 05 06:10 AM
runtime error 1004 monika Excel Programming 3 February 11th 04 09:48 AM
Runtime error 1004 Gary[_4_] Excel Programming 1 October 10th 03 02:21 PM


All times are GMT +1. The time now is 09:08 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"