Correct VBA for Getopenfilename. Why does it stop at like If strTargetFile = False Then Exit Sub

jbesclapez

Active Member
Joined
Feb 6, 2010
Messages
275
hi there,

I am trying to solve this error. It must be something stupid i do not see - I hope so.
The macro is stoping at the line If strTargetFile = "False" Then Exit Sub
I have no idea why

VBA Code:
Sub Test()
Dim wb As Workbook

strTargetFile = Application.GetOpenFilename(FileFilter:="Excel Files (*.xml*), *.xml*", Title:="Choose File To Copy", MultiSelect:=False)
 
If strTargetFile = "False" Then Exit Sub
 
      Set wb = Workbooks.OpenXML(Filename:=strTargetFile, LoadOption:=xlXmlLoadImportToList)
     Application.DisplayAlerts = True

     wb.Sheets(1).UsedRange.Copy ThisWorkbook.Sheets("Delete").Range("A1")
     wb.Close False
   
 
End Sub

Thanks for your time
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi,
try removing the quotes around "False" & see if resolves your issue

VBA Code:
If strTargetFile = False Then Exit Sub

Dave
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,254
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top