Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA to open a shortcut to a workbook

Is there a way to use VBA to "open" shortcuts to workbooks?

For example,
Book1.xls is in Folder A
There is a "shortcut" to Book1.xls in Folder B
Book2.xls is a workbook in Folder B
When opening Book2.xls, what VBA would look for shortcuts in the
Folder B and open those files?

Thanks,
Walden

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA to open a shortcut to a workbook

Sub LoopFolders()
Dim oFSO As Object
Dim Folder As Object
Dim Files As Object
Dim file As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set Folder = oFSO.GetFolder("c:\Test")

For Each file In Folder.Files
If file.Type Like "*Shortcut*" Then
Workbooks.Open Filename:=file.Path
End If
Next file

Set oFSO = Nothing

End Sub



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Walden2" wrote in message
s.com...
Is there a way to use VBA to "open" shortcuts to workbooks?

For example,
Book1.xls is in Folder A
There is a "shortcut" to Book1.xls in Folder B
Book2.xls is a workbook in Folder B
When opening Book2.xls, what VBA would look for shortcuts in the
Folder B and open those files?

Thanks,
Walden



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 477
Default VBA to open a shortcut to a workbook

All you will need to do is in Book2.xls
Alt-F11 and in the ThisWorkbook Code Window paste in:

Private Sub Workbook_Open()
LoopFolders ' Bob's code posted in a Standard module (assumed)
End Sub

Jim May



"Walden2" wrote:

Is there a way to use VBA to "open" shortcuts to workbooks?

For example,
Book1.xls is in Folder A
There is a "shortcut" to Book1.xls in Folder B
Book2.xls is a workbook in Folder B
When opening Book2.xls, what VBA would look for shortcuts in the
Folder B and open those files?

Thanks,
Walden


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA to open a shortcut to a workbook

This worked great. Thanks much.

Walden

On Oct 6, 7:48 am, "Bob Phillips" wrote:
Sub LoopFolders()
Dim oFSO As Object
Dim Folder As Object
Dim Files As Object
Dim file As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set Folder = oFSO.GetFolder("c:\Test")

For Each file In Folder.Files
If file.Type Like "*Shortcut*" Then
Workbooks.Open Filename:=file.Path
End If
Next file

Set oFSO = Nothing

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Walden2" wrote in message

s.com...



Is there a way to use VBA to "open" shortcuts to workbooks?


For example,
Book1.xls is in Folder A
There is a "shortcut" to Book1.xls in Folder B
Book2.xls is a workbook in Folder B
When opening Book2.xls, what VBA would look for shortcuts in the
Folder B and open those files?


Thanks,
Walden- Hide quoted text -


- Show quoted text -



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
shortcut has change or move so this shortcut can not open bakerstreet Excel Worksheet Functions 2 April 2nd 10 01:21 PM
Using a Windows Shortcut to Open to Specific Sheet in Workbook Staying Productive Excel Discussion (Misc queries) 4 December 22nd 09 04:37 PM
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. [email protected] Excel Programming 1 May 13th 07 01:46 PM
Write a Shortcut to Open Excel Workbook at a Specific Sheet SidBord Excel Programming 0 June 2nd 04 11:10 PM
Open a new instance with a shortcut bat_man2282[_4_] Excel Programming 0 December 22nd 03 10:04 PM


All times are GMT +1. The time now is 08:39 AM.

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

About Us

"It's about Microsoft Excel"