Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-02-2018, 07:13 AM
VBorNotVB VBorNotVB is offline Get Document Name from VB Project Mac OS X Get Document Name from VB Project Office 2016 for Mac
Novice
Get Document Name from VB Project
 
Join Date: Oct 2018
Location: Southern California
Posts: 25
VBorNotVB is on a distinguished road
Default Get Document Name from VB Project

I have a macro that iterates through all VB projects' code modules to gather information about them. The loops look like the following:

For k = 1 To Application.VBE.VBProjects.Count ' 1st one is Normal then documents
Set VBProj = Application.VBE.VBProjects(k)
If VBProj.Protection = vbext_pp_none Then ' Process code modules only


For j = 1 To VBProj.VBComponents.Count ' Iterate thru components
Set VBComp = VBProj.VBComponents(j)
Set CodeMod = VBComp.CodeModule ' Process Code Module
with CodeMod
.
.
end with

The only way I could return the name of the document (or Template in the case of Normal which is always the first VB project) that each CodeMod belongs to was from the code pane's window's caption:

sFilename = Left(.CodePane.Window.Caption, InStr(CodeMod.CodePane.Window.Caption, "-") - 2)

This worked fine in Word 2011. But I've been forced to upgrade to 2019 and the system reports an error with CodeMod.CodePane.Window.Caption now (see attachment).

Can anyone tell me how to go about getting the name of the document from the VB project or it's components/modules? All help is much appreciated!
Attached Images
File Type: png Screen Shot 2018-11-02 at 7.10.22 AM.png (30.7 KB, 18 views)

Last edited by VBorNotVB; 11-02-2018 at 07:15 AM. Reason: Title Ambiguous
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
filename field not displaying correct filename when that name starts with # plrsmith Word 1 07-06-2018 03:10 AM
How to modify the Gantt chart bar styles (label of values) in project center (WPA) (MS Project 2010) Cedahlia Project 0 04-21-2018 10:29 PM
Is it a bug or not ? Ms Project randomly changes project's tasks resources name when re-open file ? capsule Project 1 11-26-2017 06:45 AM
Project task numbering changed after linking item in subproject to m aster project rrs_2017 Project 0 09-06-2017 06:07 AM
Microsoft Project Server, Microsoft Project Online and Project Web App - Whats the difference? chocolateCupcakes Project 1 02-11-2017 12:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:52 PM.


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