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
Solved

Excel Marco problem

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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