Backing up using VBA

W

WMD

All -

I would like to create a backup macro for project files that are using a resource pool. The macro will be run from a button and will do the following: open the resource pool (if not open), break the link to the resource (if linked), change to the backup directory, do a save as with a timestamp, relink to the resource pool, close the resource pool. I have a snippet of code that I started but I am unsure on the piece that operates on the resource pool. Is the "getobject" the best way to go? or should I be using the fileopen? Snippet follows: any input here would be helpfu

Sub mBackupProject(
On Error Resume Nex
Dim prj, dtToday As Dat
Dim WD, CName, prjpool As Object, pnam

Set prj = ActiveProjec
Const BD = "Archive
WD = CurDi
CName = prj.Nam
dtToday = FormatDateTime(Now(), vbGeneralDate


pname = prj.ResourcePoolNam
If pname = CName The
ChDir BD ' change to backup director
prj.SaveAs prj.Name & "_" & dtToda
GoTo Continu
Els
Set prjpool = GetObject(pname
prjpool.Application.Visible = Tru
prjpool.parent.Windows(1).Visible = Tru

' prjpool.Application.ResourceSharingPoolAction pjUnlinkSharer, CNam
ChDir B
prj.SaveAs prj.Name & "_" & dtToda
End I
Continue
ChDir W
FileClose pjDoNotSav
Set prjpool = Nothin

End Sub
 
R

Rod Gill

Hi,
If pname = CName Then
ChDir BD ' change to backup directory
prj.SaveAs prj.Name & "_" & dtToday
'not needed> GoTo Continue
''Won't work> Set prjpool = GetObject(pname)
application.FileOpen pname
prjpool.Application.ResourceSharingPoolAction pjUnlinkSharer, CName
ChDir BD
prj.SaveAs prj.Name & "_" & dtToday
End If 'Not needed > Continue:
ChDir WD
FileClose pjDoNotSave
Set prjpool = Nothing

Rod Gill
www.projectlearning.com
WMD said:
All --

I would like to create a backup macro for project files that are using a
resource pool. The macro will be run from a button and will do the
following: open the resource pool (if not open), break the link to the
resource (if linked), change to the backup directory, do a save as with a
timestamp, relink to the resource pool, close the resource pool. I have a
snippet of code that I started but I am unsure on the piece that operates on
the resource pool. Is the "getobject" the best way to go? or should I be
using the fileopen? Snippet follows: any inpuHi,t here would be helpful
 
Top