Copy Excel File with Command Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Master Excel Workbook I need to copy every week for our
International Transfers. Never worked outside of a database before and the
example I found does not work.

The Error I get is "Object Variable or With Block Variable Not Set"

I know I am missing something, but do not know what it is.

The Code I have is below. I Execute it via a Command Button.

Dim FileSystemObject As Object
FileSystemObject.CopyFile "C:\FirstNM\FNMWeeklyMaster.xls",
"C:\FirstNM\ThisWeek.xls"

Help will be greatly appreciated!

Bill
 
Hi Bill,

There's no advantage here in a FileSystemObject: just use the VBA
FileCopy statement.

The reason your code is failing is that you aren't instantiating the
object: should have used something like
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
 
Back
Top