LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Is it possible to create a patch or update an Excel Program?

I have used the following to export a project to files and import into a
new workbook.

Note that you need to reference Microsoft Scripting Runtime and
Microsoft Visual Basic for Applications.

First, export the project from the lastest addition of your project
using the ExportProject macro. Second, open a new workbook and import
the ExportProjectModule.bas. Delete the ExportProjectModule.bas from
the "VBACode" directory so it doesn't get imported twice. Lastly run
the ImportProject macro.

I'm sure there's room for improvment on this, but I've gotten lazy.

Also I haven't found a way to delete modules from an existing workbook.
If any one know how, please let me know.

Attribute VB_Name = "ExportProjectModule"
Option Explicit

' Requires Microsoft Scripting Runtime
' Requires Microsoft Visual Basic for Applications Extensibility

Private Enum FILE_TYPE
MODULE_TYPE = 1
CLASS_TYPE = 2
FORM_TYPE = 3
End Enum

Const strPath = "C:\RPP\Test\VBACode\"

Public Sub ExportProject()

Dim fsoFileSystemObject As FileSystemObject
Dim vbComp As VBComponent

Set fsoFileSystemObject = CreateObject("Scripting.FileSystemObject")
If Not fsoFileSystemObject.FolderExists(strPath) Then
MsgBox "Folder does not exist <" + strPath + ""
Exit Sub
End If

For Each vbComp In ThisWorkbook.VBProject.VBComponents
Select Case vbComp.Type
Case FILE_TYPE.MODULE_TYPE
vbComp.Export strPath + vbComp.Name + ".bas"
Case FILE_TYPE.CLASS_TYPE
vbComp.Export strPath + vbComp.Name + ".cls"
Case FILE_TYPE.FORM_TYPE
vbComp.Export strPath + vbComp.Name + ".frm"
End Select
Next

Set fsoFileSystemObject = Nothing
Set vbComp = Nothing

End Sub

Public Sub ImportProject()

Dim fsoFileSystemObject As FileSystemObject
Dim fFolder As Folder
Dim fFile As File
Dim vbComp As VBComponent

Set fsoFileSystemObject = CreateObject("Scripting.FileSystemObject")
If Not fsoFileSystemObject.FolderExists(strPath) Then
MsgBox "Folder does not exist <" + strPath + ""
Exit Sub
End If
Set fFolder = fsoFileSystemObject.GetFolder(strPath)

For Each fFile In fFolder.Files
If fFile.Name = "ExportProjectModule.bas" Then
' Skip this file
ElseIf InStr(fFile.Name, ".bas") Then
ThisWorkbook.VBProject.VBComponents.Import strPath + "\" +
fFile.Name
ElseIf InStr(fFile.Name, ".cls") Then
ThisWorkbook.VBProject.VBComponents.Import strPath + "\" +
fFile.Name
ElseIf InStr(fFile.Name, ".frm") Then
ThisWorkbook.VBProject.VBComponents.Import strPath + "\" +
fFile.Name
End If
Next

Set fsoFileSystemObject = Nothing
Set fFolder = Nothing
Set fFile = Nothing
Set vbComp = Nothing

End Sub



*** Sent via Developersdex http://www.developersdex.com ***
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel patch whacky Lark Excel Discussion (Misc queries) 1 September 6th 08 02:58 AM
Why does my excel program create a .xls:1 extension? Laura Excel Discussion (Misc queries) 2 April 12th 05 10:16 PM
Excel fun patch [email protected] Excel Discussion (Misc queries) 0 March 23rd 05 03:20 AM
Is there a way to create a program in excel to compare files? bruce Excel Programming 7 June 5th 04 07:58 PM
creating a 'patch' for excel workbooks Scott Excel Programming 1 August 27th 03 02:57 PM


All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"