LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Problems open workbook via macro




Hi

I have a problem with the code below.
The macro search for the latest version of a file and then open it and
close itsef.

If I open the file containing this macro in the usual way it works as it
should.

But if I open it via a hyperlink doese't work.

The macro runs with no error but only the file with the hyperlink is
shown.
Någon som vet vad som är fel och vill hjälpa mig?

Thanks in advance

Private Sub Workbook_Open()
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim Version As Integer
Dim Temp as Integer
Dim CurrentFile As String
Dim Projekt_Folder As String

Projekt_Folder = "folder"

Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(Projekt_Folder)
For Each FileItem In SourceFolder.Files
If Right(UCase(FileItem.Name), 4) = ".XLS" And
Left(FileItem.Name, 10) = "abcdefgh.v" Then
If Not IsNumeric(Left(Right(FileItem.Name, 6), 2)) Then GoTo
NotANumber
Temp = Left(Right(FileItem.Name, 6), 2)
If Temp Version Then
Version = Temp
CurrentFile = FileItem.Name
End If
NotANumber:
On Error GoTo 0

End If
Next FileItem
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
On Error Resume Next
Workbooks.Open Projekt_Folder & CurrentFile, , True

ThisWorkbook.Close False
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
 
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
Enable macro message on VBA Workbook Open then macro ends Barb Reinhardt Excel Programming 2 July 15th 08 03:59 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
Open workbook macro- find correct month to open? buzzharley[_10_] Excel Programming 8 July 8th 06 04:30 AM
Problems in running a macro in another workbook dhatul Excel Discussion (Misc queries) 3 January 20th 06 08:01 AM
WorkBook.Open: Problems with field separation character Ebbe Excel Programming 7 September 12th 04 06:34 PM


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