如何将VB6项目部署到服务器上,如何将整个VB6项目保存到新文件夹?模块和所有...

Option Explicit

Public VBInstance As VBIDE.VBE

Public Connect As Connect

Private Sub CancelButton_Click()

Connect.Hide

End Sub

Private Sub OKButton_Click()

On Error Resume Next

Dim strProject As String

Dim strPath As String

Dim strPath2 As String

Dim strFile As String

Dim strPrjFile As String

Dim rst As VbMsgBoxResult

Dim m, n As Long

Dim col2 As Collection, col As Collection

Dim vbCom As VBComponent

Dim fso As FileSystemObject

Dim ts As TextStream

Dim f1 As String, f2 As String

strProject = Me.VBInstance.ActiveVBProject.FileName

strPath = ParseFileName(strProject, strPrjFile)

strPath2 = setFolder

If strPath = "" Or strPath = strPath2 Then

MsgBox "target folder is invalid or same as the project folder. Can't copy."

Exit Sub

End If

Set col2 = New Collection

Set col = New Collection

Set fso = New FileSystemObject

Set ts = fso.CreateTextFile(strPath2 & "wemeet.log", False)

For m = Me.VBInstance.ActiveVBProject.VBComponents.Count To 1 Step -1

Set vbCom = Me.VBInstance.ActiveVBProject.VBComponents(m)

For n = 1 To vbCom.FileCount

f1 = vbCom.FileNames(n)

ParseFileName f1, strFile

f2 = strPath2 & "" & strFile

fso.CopyFile f1, f2

col.Add f1

col2.Add f2

ts.WriteLine "" & Now() & " [Move]: " & f1

ts.WriteLine "" & Now() & " [To ]: " & f2

ts.WriteBlankLines 1

Next

Me.VBInstance.ActiveVBProject.VBComponents.Remove vbCom

Next

For m = 1 To col2.Count

Me.VBInstance.ActiveVBProject.VBComponents.AddFile col2.Item(m)

ts.WriteLine "" & Now() & " [Add]: " & col2.Item(m)

ts.WriteBlankLines 1

Next

Me.VBInstance.ActiveVBProject.SaveAs strPath2 & "" & strPrjFile

ts.WriteLine "" & Now() & " [SaveAs]: " & strPath2 & "" & strPrjFile

ts.WriteBlankLines 1

ts.Close

fso.OpenTextFile strPath2 & "wemeet.log"

Set fso = Nothing

Set col = Nothing

Set col2 = Nothing

Set vbCom = Nothing

Connect.Hide

End Sub

Private Function ParseFileName(ByVal sPath As String, ByRef sFile As String) As String

Dim fso As New FileSystemObject

If fso.FileExists(sPath) Then

ParseFileName = fso.GetParentFolderName(sPath)

sFile = fso.GetFileName(sPath)

Else

ParseFileName = ""

sFile = ""

End If

Set fso = Nothing

End Function

Private Function setFolder() As String

Dim objDlg As Object

Dim objStartFolder As Object

Set objDlg = CreateObject("Shell.Application")

Set objStartFolder = objDlg.BrowseForFolder(&H0, "Select a folder", &H10 + &H1)

If InStr(1, TypeName(objStartFolder), "Folder") > 0 Then

setFolder = objStartFolder.ParentFolder.ParseName(objStartFolder.Title).Path

End If

Set objDlg = Nothing

End Function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值