Really strange!! Switch/Open code fails occasionaly?!

  • Thread starter Leanne M (Aussie)
  • Start date
L

Leanne M (Aussie)

Hi,

I have the following code to switch/open a workbook.

Private Sub CommandButton3_Click()
s = "file:///c:\My Documents\Pest Control Management System\Pest Control
Reporting Tool.xls"
ActiveWorkbook.FollowHyperlink Address:=s
Application.CommandBars("Web").Visible = False
End Sub

This is one two workbooks and the code is exactly the same (with the
exception of the file name). On one of the workbooks the code works, on the
other it does not. I get a messaging saying 'Object invalid or not found'

This is only (so far) happening on my husbands pc (windows vista excel
2003). The code works in both instances on my pc and the one at work.

Any ideas as this has me baffled (though thats not hard these days!)
 
J

Joel

I don't know much about Vista but I do know 2003. There are two forms for
webaddress that 2003 uses

1) s = "c:\dir1\sub1"
or
2) s = "//www.microsoft.com/sub1"


I don't think 2003 likes both the double slashes and the directory (c:).
 
L

Leanne M (Aussie)

Hi,

Thanks for this information.

If I understand you correctly, I should remove the

file:///

part of the code and then this should work each time.

The web command bar is just because for some reason it makes this visible
and I know my users will freak out when their screen changes! They know very
little about Excel - and computers for that mater!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top