SAVEAS OR MOVE VIA VBA

G

Guest

With the code below I open a student file and do a error check to grade.
How do I move the workbook after correction to a new folder one level deeper
in the directory?
Move to "L:\OFFICE SKILLS\STUDENT DATA ENTRY" & _
"\Corrected\Dave S\Data Entry GRP#_3.xls"
Then if I can get the file moved I no longer need the original.

The problem seems to be the fact that I use the "GetOpenFileName"
But I use this as the file name changes each depending on the student
and thier progress.

Unsure how to modify the value returned from the GetOpenFileName command.



Private Sub CommandButton3_Click()

SwitchBoard.Hide

FName = Application.GetOpenFilename _
(filefilter:="Excel Files (*.xls),*.xls")
Workbooks.Open (FName)

Worksheets("ERROR REPORT").Activate
Calculate

' PRINT
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
' DISPLAY
'ActiveWindow.SelectedSheets.PrintPreview
' Print or Display.

Worksheets("Data Entry").Activate
Worksheets("Data Entry").Range("A1").Select
ActiveWorkbook.Close SaveChanges:=False
SwitchBoard.Show
End Sub
 
T

Tom Ogilvy

Private Sub CommandButton3_Click()

SwitchBoard.Hide

FName = Application.GetOpenFilename _
(filefilter:="Excel Files (*.xls),*.xls")
Workbooks.Open (FName)

Worksheets("ERROR REPORT").Activate
Calculate

' PRINT
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
' DISPLAY
'ActiveWindow.SelectedSheets.PrintPreview
' Print or Display.

Worksheets("Data Entry").Activate
Worksheets("Data Entry").Range("A1").Select
sPath = ActiveWorkBook.Path
on error goto ErrHandler:
Activeworkbook.SaveAs sPath & "\onelower\" & activeworkbook.Name
Kill FName
SwitchBoard.Show
ErrHandler:
msgbox FName & " not successfully copied"
End Sub
 
G

Guest

Thank you very much.
I just did not know were to go with it.
Knew it was somthing simple, but that only made it harder.

Dan
 

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

Top