Solved

Excel Marco problem

Posted on 2014-09-18
2
243 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Photo Albums in PowerPoint Photo Albums are a very useful tool in PowerPoint and allow you quickly add a large number of images. The images can be formatted in a variety of ways so that you are able to create a professional looking presentation v…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now