Excel Marco problem
Posted on 2014-09-18
I have a excel spreadsheet that has a VBscript that runs and saves my file to another location. When it runs it has an error
"The following features cannot be saved in macro-free workbook. VB project." . then when I open the newly saved file the VBscript is no longer there. How do I get around this problem. This is the code that opens the file to be saved later
InputPath = "T:\Occupational Therapy\" ' this is the folder with the Data file. **** CHANGE THIS TO REFLECT YOUR PATH ****
InputFile = "Med-A-Therapy.xlsm" ' this is the file name of the Data file. **** CHANGE THIS TO YOUR DATA FILE NAME ****
PatientNumber = SourceSheet.Range("F5").Value ' the patient number in cell E5 of the current file
OutputPath = "T:\Occupational Therapy\Export Files\" ' this is the folder where the new file must be saved **** CHANGE THIS TO REFLECT YOUR PATH ****
OutputFile = PatientNumber & " Med A OC" & ".xlsm" ' this is the file name of the new file, using the patient number
and this is the code that will save the file.
save the data file as a new file in the output folder, with the patient number as the name.
ActiveWorkbook.SaveAs Filename:=OutputPath & OutputFile, FileFormat:= _
TargetFile.Close ' close the newly saved file
SourceFile.Close ' close the source file
The Script works great but for this error. any help would be great. thank you.