Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
I have created this macro to open an excel file; but if a file is not selected
than end up in error, is there a way to stop the macro without an error this is what i have Sub OpenWorkbok() Dim fName As String fName = Application.GetOpenFilename() Workbooks.Open Filename:=fName End Sub |
#2
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Hi
Sub OpenWorkbok() Dim fName As String fName = Application.GetOpenFilename() If fname < "" Then Workbooks.Open Filename:=fName End If End Sub -- Regards Roger Govier "Exceldude" wrote in message ... I have created this macro to open an excel file; but if a file is not selected than end up in error, is there a way to stop the macro without an error this is what i have Sub OpenWorkbok() Dim fName As String fName = Application.GetOpenFilename() Workbooks.Open Filename:=fName End Sub |
#3
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Option Explicit
Sub OpenWorkbok() Dim fName As Variant 'could be the boolean false fName = Application.GetOpenFilename if fname = false then 'user hit cancel else workbooks.Open Filename:=fName end if End Sub Exceldude wrote: I have created this macro to open an excel file; but if a file is not selected than end up in error, is there a way to stop the macro without an error this is what i have Sub OpenWorkbok() Dim fName As String fName = Application.GetOpenFilename() Workbooks.Open Filename:=fName End Sub -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Thank you Dave,
that was exactly what I needed; it works Great "Dave Peterson" wrote: Option Explicit Sub OpenWorkbok() Dim fName As Variant 'could be the boolean false fName = Application.GetOpenFilename if fname = false then 'user hit cancel else workbooks.Open Filename:=fName end if End Sub Exceldude wrote: I have created this macro to open an excel file; but if a file is not selected than end up in error, is there a way to stop the macro without an error this is what i have Sub OpenWorkbok() Dim fName As String fName = Application.GetOpenFilename() Workbooks.Open Filename:=fName End Sub -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Discussion (Misc queries) | |||
Macro error please help | Excel Discussion (Misc queries) | |||
Macro error : Application-defined or object-defined error | Excel Discussion (Misc queries) | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) |