Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-24-2018, 07:52 PM
AnnaNmty AnnaNmty is offline OrganizerCopy method for ActiveDocument Windows 7 64bit OrganizerCopy method for ActiveDocument Office 2010 64bit
Novice
OrganizerCopy method for ActiveDocument
 
Join Date: Jul 2018
Posts: 2
AnnaNmty is on a distinguished road
Default OrganizerCopy method for ActiveDocument

When running the following code with the document I want to replace the style in open, I get a "File in Use" (Test.docx is locked for editing... ) window.



It seems to make a different how the file is opened though, and I am hoping one of you can explain why that is. If I open the file using File >Open within Word and then run the macro, it works. However, that is not a typical workflow for me—I usually open a file by clicking on it.

Code:
Sub ReplaceStyles()

Dim DocSource
Dim myFile

DocSource = "C:\Users\myname\Desktop\EXAMPLE.docx"
Set myFile = ActiveDocument
'myFile = "full path to document.docx"

    Application.OrganizerCopy Source:=DocSource, Destination:=myFile, Object:=wdOrganizerObjectStyles, _
    Name:="Caption-Photo"

End Sub
The eventual code will update/add many styles. I wish to do this via a macro rather than attaching a template.

Word 2010, Windows 7
Reply With Quote
 

Tags
active document, styles

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
OrganizerCopy method for ActiveDocument Loop through listboxes in Application.OrganizerCopy Marrick13 Word VBA 50 04-16-2024 01:21 PM
ActiveDocument.ContentControls(ID) not working Tejas.T Word VBA 3 03-09-2015 06:50 PM
Loop through listboxes in Application.OrganizerCopy-revisited Marrick13 Word VBA 0 12-06-2014 06:07 AM
wordapp.ActiveDocument.SaveAs Not Working KSReynolds Mail Merge 1 07-18-2014 04:03 PM
OrganizerCopy method for ActiveDocument Using With ActiveDocument.Tables() SuzeG Word VBA 1 01-08-2014 02:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft