Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I run code in MSProject from Acc97 1

Status
Not open for further replies.

shar

Technical User
Apr 2, 2000
54
0
0
IR
I use access 97 to export data into an Excel file. I have written code in MS Project to import the data from the Excel file and perform modifications and formatting. In Acc97, I can export the data to the Excel file and start MS Project, but I cannot run the codes in MS Project. The SendKeys command doesn't work. Is there a way to run the codes that reside in MSProject global template from Acc97?

Thanks.
 
The sub below is run from Outlook and is automatically triggered to check for a specific value in the Outlook Calendar appointments. It triggers an Excel macro using automation. This same function could run in Access IF it used not project controls. My Add-In name is PERSONAL_ENHANCED.XLA which contains the macros.

Public Sub RunReports()

Dim myXlApp As Excel.Application
Dim myBook As Excel.Workbook
Dim pathSep As String
Dim libItem As String
Dim strActiveBook As String
Dim strMacro As String
Dim Item As Integer

If UBound(Appts) < 0 Then
Exit Sub
End If

On Error Resume Next

Set myXlApp = GetObject(Class:=&quot;Excel.Application&quot;)
If myXlApp Is Nothing Then
Set myXlApp = New Excel.Application
End If

pathSep = myXlApp.PathSeparator
libItem = myXlApp.StartupPath & pathSep & &quot;PERSONAL_ENHANCED.Xla&quot;
myXlApp.Workbooks.Open filename:=libItem
myXlApp.Workbooks.Add
Set myBook = myXlApp.ActiveWorkbook
myXlApp.Visible = True

' Find out if this is already identified
' you only want to run it once

For Item = 0 To UBound(Appts)
Debug.Print Appts(Item).Subject
strMacro = Appts(Item).Subject
Do While InStr(1, strMacro, &quot; &quot;) > 0
strMacro = Mid$(strMacro, 1, InStr(1, strMacro, &quot; &quot;) + 1)
Loop
strMacro = &quot;PERSONAL_ENHANCED.XLA!&quot; & strMacro
myXlApp.Run Macro:=strMacro
Appts(Item).myAppt.ReminderSet = False
Appts(Item).myAppt.Save
Next Item

End Sub

---------------------
scking@arinc.com
---------------------
 
Thank you scking. Your code helped me to get what I needed to do. Sorry for the delay in response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top