File Loading Problems

  • Thread starter Thread starter Jason Hancock
  • Start date Start date
J

Jason Hancock

Okay, here is the problem. The code below crashes out at the
Windows(UFFN).Activate part. I think that the code is assigning False
to the UF instead of assigning the input from the selection window. Is
there some other way to make sure that the then statement runs when the
click Cancel.

While I'm thinking about it, is there some way to make sure the write
restriction password dialog box doesn't appear?

Dim UF As Variant
Dim UFFN As Variant
UF = Application.GetOpenFilename(Title:="This Weeks Projections for
Angie")
If UF <> False Then

Workbooks.Open Filename:=UF

Set wbUF = Workbooks.Open(Filename:=UF,
WriteResPassword:="sue")
UFFN = wbUF.Name

Windows(UFFN).Activate
Sheets("Angie").Select
Sheets("Angie").Copy After:=Workbooks("Projection
Summary.xls").Sheets("Summary")
Windows(UFFN).Activate
ActiveWindow.Close
Windows("Projection Summary").Activate

Else

MsgBox "No projection forms selected for Angie. You must
add them manually later."


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
I think I'd stop using the Windows collection.

Maybe something like:

Option Explicit
Sub testme02()

Dim UF As Variant
Dim wbUF As Workbook

UF = Application.GetOpenFilename(Title:="This Weeks Projections for Angie")
If UF <> False Then
Set wbUF = Workbooks.Open(Filename:=UF, WriteResPassword:="sue")

wbUF.Sheets("angie").Copy _
after:=Workbooks("Projection summary.xls").Sheets("summary")
'or after:=thisworkbook.sheets("summary")

wbUF.Close savechanges:=False
Else
MsgBox "No projection forms selected for Angie. You must" _
& " add them manually later."
End If
End Sub

Untested, but it compiled ok.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top