Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-13-2019, 05:28 PM   #1
mdlueck
Sr. Application Developer
 
Join Date: Jun 2011
Posts: 2,621
Thanks: 113
Thanked 295 Times in 283 Posts
mdlueck will become famous soon enough mdlueck will become famous soon enough
Incomplete results mass exporting Access VBA modules

Greetings,

I have tried two methods to export VBA modules. Neither for me produce complete hidden headers that the manual export user interface includes. This results in VBA not being able to import them successfully.

I have tried the following two VBA implementations:

1) VCS code originated from https://github.com/timabell/msaccess-vcs-integration/

which uses this method to extract out from Access / VBA the individual module files:

Application.SaveAsText obj_type_num, obj_name, file_path

2) When I discovered the error with this, then I found this other way to do "the same thing"...

Code:
  Set appAccess = CreateObject("Access.Application")
  appAccess.OpenCurrentDatabase (strAccessDBFullFilename)

  Set objProj = appAccess.VBE.ActiveVBProject

  If objProj Is Nothing Then
    Debug.Print "ExportModule_ExportAllModules objProj was Nothing"
    GoTo Exit_ExportModule_ExportAllModules
  End If

  For Each objComponent In objProj.VBComponents
    'Export the files as *.bas files
    objComponent.Export strAccessModuleExportFullPath & objComponent.Name & ".bas"
  Next objComponent
The issue both of these automated methods have:

Manually exported via the VBA editor has the following header lines before the VBA code:

Code:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "clsObjProjectsTbl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
When I use either of these VBA automated ways of exporting the same module, the resulting export file only has these header lines:

Code:
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
How do I get around this bug and successfully export via VBA automation?

I am thankful,

__________________
--
Michael Lueck
Lueck Data Systems

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
mdlueck is offline   Reply With Quote
Old 06-13-2019, 07:52 PM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,981
Thanks: 34
Thanked 714 Times in 697 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Incomplete results mass exporting Access VBA modules

Hi Michael. I haven't done anything like this before, so although I just gave it a try, I cannot promise if this is the correct way to do it. However, when I executed the following command in the Immediate Window, I got the same output as if I had done it manually.
Code:
Application.VBE.SelectedVBComponent.Export CurrentProject.Path & "\test1.txt"
Since the above was basically done "manually" because I had the class module selected in the VBE window, I then executed the following line just to see if it can be done without selecting the module first.
Code:
Application.VBE.ActiveVBProject.VBComponents.Item(5).Export CurrentProject.Path & "\test2.txt"
This time, it worked as intended. It didn't matter which module I had selected, it always exports the specific item I entered in the code. Hopefully, you can use this. But if you find a better way, please let us know. Thanks.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 06-13-2019, 11:31 PM   #3
Gasman
Enthusiastic Amateur
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 3,661
Thanks: 398
Thanked 634 Times in 615 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Incomplete results mass exporting Access VBA modules

As do I, but I get none of those headers at all.?

My first few lines.

Code:
Attribute VB_Name = "Module2"
Option Compare Database
Public Function Previous(strFormName As String, strFieldName As String)

__________________
Access novice. Sometimes trying to give something back.
Access 2007


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 06-19-2019, 06:07 PM   #4
mdlueck
Sr. Application Developer
 
Join Date: Jun 2011
Posts: 2,621
Thanks: 113
Thanked 295 Times in 283 Posts
mdlueck will become famous soon enough mdlueck will become famous soon enough
Re: Incomplete results mass exporting Access VBA modules

Odd... my #2 version of the module exporter above this evening IS exporting all of the header lines. Perhaps I just forgot to re-export all the modules after writing the #2 version, thus thought it defective as well.

I am thankful,
__________________
--
Michael Lueck
Lueck Data Systems

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
mdlueck is offline   Reply With Quote
Old 06-19-2019, 06:17 PM   #5
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,981
Thanks: 34
Thanked 714 Times in 697 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Incomplete results mass exporting Access VBA modules

Quote:
Originally Posted by mdlueck View Post
Odd... my #2 version of the module exporter above this evening IS exporting all of the header lines. Perhaps I just forgot to re-export all the modules after writing the #2 version, thus thought it defective as well.

I am thankful,
Hi Michael. Glad to hear you got it sorted out. Good luck!

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting table to XML incomplete ths Tables 3 12-13-2012 02:21 PM
Strange results on exporting an Access Form to XL cyd44 Modules & VBA 1 07-12-2012 09:41 AM
Query returns incomplete results jiblankman Modules & VBA 0 08-18-2009 10:11 AM
Incomplete Data Export - when exporting a table to excel JarvisC Tables 2 06-09-2008 11:42 PM
combobox results incomplete pbuethe Queries 1 04-20-2006 04:50 AM




All times are GMT -8. The time now is 12:54 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World