Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Enable macro message on VBA Workbook Open then macro ends | Excel Programming | |||
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. | Excel Programming | |||
Open workbook macro- find correct month to open? | Excel Programming | |||
Problems in running a macro in another workbook | Excel Discussion (Misc queries) | |||
WorkBook.Open: Problems with field separation character | Excel Programming |