P
Pam
I have 6 divisions, each division has 3 branches, each
branch has multiple project leads working in MS Project,
however saving the project files to their specific branch
location. For example: on a shared network, a project
lead in MACD Branch saves his project files to:
J:\Projects\AFMIA MAC\MACD\.
I have a macro that will print the notes for the project
into a ".txt" file. I want the .txt file to be stored in
the appropriate branch folder when the macro is ran.
Currently, the macro stores the results in the
generic "J" drive.
What I need is to be able to capture the path the project
lead is in when he runs the macro, and have the .txt file
print to his branch folder.
My code is as follows:
Option Explicit
Sub NoteFile()
Dim MyString As String
Dim MyFile As String
Dim fnum As Integer
Dim myTask As Task
'set location and name of file to be written
MyFile = "J:\Projects\" & ActiveProject.Name
& "_Project_Notes" & ".txt"
'set and open file for output
fnum = FreeFile()
Open MyFile For Output As fnum
'Build string with project info
MyString = ActiveProject.Name _
& " " _
& ActiveProject.CurrentDate _
& " " _
& Application.UserName
'write project info and then a blank line
Write #fnum, MyString
Write #fnum,
'step through tasks and write notes for each then a blank
line
For Each myTask In ActiveProject.Tasks
If myTask.Notes <> "" Then
'edit the following lne to include the fields you
want
'use " " to include any text or spaces.
MyString = myTask.UniqueID & ": " & myTask.Name
& ": " & myTask.Notes
'Some other examples: MyString = MyTask.Text1
& ": " & MyTask.Start
Write #fnum, MyString
Write #fnum,
End If
Next myTask
Close #fnum
End Sub
Obviously from the MyFile line, I have the .txt results
going to the J drive. I can change that line of code to
send it directly to the appropriate branch folder:
MyFile = "J:\Projects\AFMIA MAC\MACD\" &
ActiveProject.Name & "_Project_Notes" & ".txt"
I just don't want to have to hard code the SAVE area in
each project. I want the macro included in our project
templates and adjust itself to the proper folder. Can
this be done?
branch has multiple project leads working in MS Project,
however saving the project files to their specific branch
location. For example: on a shared network, a project
lead in MACD Branch saves his project files to:
J:\Projects\AFMIA MAC\MACD\.
I have a macro that will print the notes for the project
into a ".txt" file. I want the .txt file to be stored in
the appropriate branch folder when the macro is ran.
Currently, the macro stores the results in the
generic "J" drive.
What I need is to be able to capture the path the project
lead is in when he runs the macro, and have the .txt file
print to his branch folder.
My code is as follows:
Option Explicit
Sub NoteFile()
Dim MyString As String
Dim MyFile As String
Dim fnum As Integer
Dim myTask As Task
'set location and name of file to be written
MyFile = "J:\Projects\" & ActiveProject.Name
& "_Project_Notes" & ".txt"
'set and open file for output
fnum = FreeFile()
Open MyFile For Output As fnum
'Build string with project info
MyString = ActiveProject.Name _
& " " _
& ActiveProject.CurrentDate _
& " " _
& Application.UserName
'write project info and then a blank line
Write #fnum, MyString
Write #fnum,
'step through tasks and write notes for each then a blank
line
For Each myTask In ActiveProject.Tasks
If myTask.Notes <> "" Then
'edit the following lne to include the fields you
want
'use " " to include any text or spaces.
MyString = myTask.UniqueID & ": " & myTask.Name
& ": " & myTask.Notes
'Some other examples: MyString = MyTask.Text1
& ": " & MyTask.Start
Write #fnum, MyString
Write #fnum,
End If
Next myTask
Close #fnum
End Sub
Obviously from the MyFile line, I have the .txt results
going to the J drive. I can change that line of code to
send it directly to the appropriate branch folder:
MyFile = "J:\Projects\AFMIA MAC\MACD\" &
ActiveProject.Name & "_Project_Notes" & ".txt"
I just don't want to have to hard code the SAVE area in
each project. I want the macro included in our project
templates and adjust itself to the proper folder. Can
this be done?