?
Solved

Excel Marco problem

Posted on 2014-09-18
2
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 2000 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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

770 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