Dave - Followup questions for GetOpenFilename


Posted by SHANE on May 02, 2001 7:31 AM

Dave - At bottom is the code you provided to avoid links. I have a few follow up questions.

(1) I get a program error if I include the following code "If SfileToOpen = False Then Exit Sub" but if I leave it out the macro seems to work.
(2) If I want to update links after I've opened a file with this function, how can I do it?
(3) If I save a file after performing this function, will I be able to update the links if I open the file again.
(4) how can I make this function easily available to multiple users who may not be code or even macro savvy?

Sooooo many questions.
Thanks tons!


Shane, I wouldn't rely on users to type in file names into a InputBox, they WILL stuff it upe every time :o) Use the GetOpenFileName instead.

Sub TryThis()
Dim SfileToOpen As String
SfileToOpen = Application.GetOpenFilename
If SfileToOpen = False Then Exit Sub
Workbooks.Open FileName:=SfileToOpen, UpdateLinks:=0
End Sub


Dave




Posted by Dave Hawley on May 03, 2001 4:36 AM


Hi Shane

My fault, I used False as a Boolean instead of a String. Try this code:

Sub TryThis()
Dim SfileToOpen As String
SfileToOpen = Application.GetOpenFilename
If SfileToOpen = "False" Then Exit Sub
Workbooks.Open Filename:=SfileToOpen, UpdateLinks:=0
End Sub


To update links any time after the file has opened go to Edit>Links and select "Update now"

If you save the file after opening a Workbook without Updating links, the file will still update next to you open.

To make the code available to others you can either assign a shortcut key, attached to a button or menubar item.

Dave
OzGrid Business Applications