VBA Save File issue after move to Excel 2010

Silvanus

New Member
Joined
Oct 28, 2011
Messages
43
To any takers...

My company just recently moved to Office 2010 from 2003, and one of my macros is giving me:

Run-time error '5353':

You cannot save while the file is in use by another process. Try saving the file with a new name.

The specific part of the code copies a reworked portion of data from excel to microsoft word and saves it to a folder on my desktop.

Code:
Set AppWD = CreateObject("Word.Application")
    AppWD.Documents.Add
Workbooks("Positive Pay Upload Creator").Sheets("Compiled").Activate
Workbooks("Positive Pay Upload Creator").Sheets("Compiled").Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Copy
    
' Paste the copied data into the new Word document in text format, to prevent formatting
' the data as a table.  Save the file in TextLineBreaks format to retain line breaks, but
' remove all other text formatting in the output file.
    AppWD.Selection.PasteSpecial DataType:=wdPasteText
    [COLOR=#ff0000]AppWD.ActiveDocument.SaveAs Filename:=OutputDataLocn, _
        FileFormat:=wdFormatTextLineBreaks
[/COLOR]    AppWD.ActiveDocument.Close
    AppWD.Quit

The code in red is where it breaks. I can post the entire sub procedure if it helps, but I'm hoping someone has had issues like this before. I've already enabled the Microsoft Word object library through Tools>References in VBA window.

Any help would be much appreciated, I'm totally stuck.

Thanks!

Running Excel 2010 recently upgraded from 2003 on a windows XP machine.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top