View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Changing the active workbook

just to throw my 2 cents worth in, you probably need to add an error handler
in case there's a problem opening the file, or you just hit the cancel
button


Dim wkbCustomReport As Workbook
Dim wkbOtherWorkbook As Workbook
Dim strFile As String

Set wkbCustomReport = ThisWorkbook
strFile = Application.GetOpenFilename("Text Files (*.txt),*.txt," & _
"Excel Files (*.xls), *.xls", 2)
If strFile < "" Then
On Error GoTo 1
Set wkbOtherWorkbook = Workbooks.Open(strFile)

End If
1:
End Sub

--


Gary


"SP" wrote in message
oups.com...
Thanks for explaining the process, I've used Excel for a long time but
I'm just starting to write code.

Sal