View Single Post
 
Old 07-25-2018, 12:36 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,978
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

How you open the myFile document is irrelevant UNLESS you have created a new document and the file has not yet been given a name and filepath location. But you do have some other issues with your code that would also be failure points.

OrganizerCopy expects the Source and the Destination to both be of type string. You supplied one string and one document so that would be a likely point of failure.
Secondly, myFile may not be saved yet and therefore its path doesn't yet exist
Thirdly, myFile may not be writeable. You can open a document but it could be opened in Read Only mode. The error message sounds like this is likely to be the problem.
Fourthly, DocSource may not exist or be readable.
Finally, does the style called 'Caption-Photo' exist in the DocSource file? It's not a built-in style name so there is always the danger that it doesn't exist.

If you choose to do this manually, style by style that is your prerogative but it can be done with a single line if you used an attached template - Just saying...
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote