Solved

Excel Marco problem

Posted on 2014-09-18
2
252 Views
Last Modified: 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.
    TargetFile.Activate
    ActiveWorkbook.SaveAs Filename:=OutputPath & OutputFile, FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
    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.
0
Comment
Question by:jodyreid
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40330664
Change

 xlOpenXMLWorkbook

to

xlOpenXMLWorkbookMacroEnabled
0
 

Author Closing Comment

by:jodyreid
ID: 40330716
Thank you very much. It works great now. Thank you again
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With the internet and the ease of information transference, many professional jobs can be done anywhere today.  Why should it make a difference whether an x-ray is read in India or the United States as long as the radiologist is qualified?   Outso…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question