Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-25-2014, 12:56 PM
Cosmo Cosmo is offline Looking for best way to remove VBA and CustomUI from a file via VBA Windows Vista Looking for best way to remove VBA and CustomUI from a file via VBA Office 2007
Competent Performer
Looking for best way to remove VBA and CustomUI from a file via VBA
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default Looking for best way to remove VBA and CustomUI from a file via VBA

I have a document which contains a CustomUI ribbon and VBA modules to allow a user to customize the content and saves a copy of the document for each customer. I need to remove the CustomUI and the VBA components (Modules and UserForms) from the finalized document, but I have not found a reliable method to do so yet.



I tried applying the 'Normal.docm' template to the finalized document, but that seemed to work at first, but doesn't seem to be working anymore (i.e. the CustomUI is still used, and the VBA modules are still intact in the copy). I'm not sure if the file format I am saving the document may affect this or not, I am saving it as wdFormatXMLDocument.

I also tried looping through the document.VBProject.VBComponents to remove them, but this requires the 'Trust access to the VBA project object model' to be checked, and I cannot be sure that the user will have this option selected.

I tried saving the document in wdFormatXMLDocument (.docx format removes the VBA modules), then closing and reopening the document and saving as wdFormatDocument (.doc format removes the CustomUI), which worked fine on my computer (aside from changing the format of some of the bulleted text), but then the client was getting the 'Word cannot start the converter mswrd632.wpc' error when saving as .doc files.

Is there a more reliable way to remove these parts of the document via VBA?
Reply With Quote
  #2  
Old 04-25-2014, 06:19 PM
macropod's Avatar
macropod macropod is offline Looking for best way to remove VBA and CustomUI from a file via VBA Windows 7 32bit Looking for best way to remove VBA and CustomUI from a file via VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you store the macros & useforms in the document template, they'll be available on whatever system the template is available, but not otherwise (because they don't get added to the document). The only reasons the code would remain in the document are:
1. You're using a document as a template, instead of using a template; or
2. The code specifically written to add itself to the document (which isn't something you're likely to have achieved by accident).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for best way to remove VBA and CustomUI from a file via VBA excel cannot open the file .xlsx because the file format or file extension is not val teddysika Excel 1 11-22-2012 06:06 AM
Remove first character from text file dwillyfan Word VBA 1 09-04-2012 08:29 PM
How to remove password from .docx file? erik2282 Word 3 05-29-2012 05:44 AM
Looking for best way to remove VBA and CustomUI from a file via VBA How to remove "Table of Figures" as we do to remove the "Table of Contents"? Jamal NUMAN Word 1 07-08-2011 05:40 PM
Problem with Workbook_Open with CustomUI birdseye42 Excel 0 08-26-2009 11:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:34 PM.


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