I am stuck.
The macro puts all of the entered information into excel and then I have the macro open word to fill auto fill a form. I got as far as opening the docuemnt from the excel, but I keep getting an error that a "document is not open" to put the collected info into the form. Below is the code. I then will send a copy, by e-mail, to accounting. This all worked fine until we updated our documents into word.
Private Sub SendPI_Form()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim MyWord As Word.Application
Set MyWord = CreateObject("Word.Application")
MyDoc = "P:\Office Tools\Administrative\Forms\Office 2003\Kansas City\Project Initialization Form.doc"
MyWord.Documents.Open (MyDoc)
MyWord.Visible = True
'I am stuck here
Windows("Project Initialization Form.doc").Activate
ActiveDocument.Bookmarks("RequestBy").Select
Selection.TypeText Text:="208"
ActiveDocument.Bookmarks("Date").Select
Selection.TypeText Text:=MonthName(Month(Date)) & " " & Day(Date) & " , " & Year(Date)
If NewProj.Value = True Then
ActiveSheet.OLEObjects("NewProject").Object.Value = True
End If
ActiveDocument.Bookmarks("ProjectNo").Select
Selection.TypeText Text:=IntlProjBlng.ProjNo
ActiveDocument.Bookmarks("ProjectDesc").Select
Selection.TypeText Text:=IntlProjBlng.ProjDesc
ActiveDocument.Bookmarks("PhaseNo").Select
Selection.TypeText Text:=IntlProjBlng.PhsNo
ActiveDocument.Bookmarks("PhaseDesc").Select
Selection.TypeText Text:=IntlProjBlng.PhsDesc
ActiveDocument.Bookmarks("IntOwner").Select
Selection.TypeText Text:=IntlProjBlng.IntOwnr
ActiveDocument.Bookmarks("RFCNo").Select
Selection.TypeText Text:=IntlProjBlng.RFCNo
ActiveDocument.Bookmarks("BillingType").Select
Selection.TypeText Text:=IntlProjBlng.BlngType
ActiveDocument.Bookmarks("BudgetAmount").Select
Selection.TypeText Text:=IntlProjBlng.FeeBud
ActiveDocument.Bookmarks("ProjectDate").Select
Selection.TypeText Text:=IntlProjBlng.InitDate
ActiveDocument.Bookmarks("InvVerb").Select
Selection.TypeText Text:=IntlProjBlng.InvoiceTxt
'Send E-mail to Accounting
ActiveWorkbook.SendMail Recipients:="user", Subject:=("Project Initialization Form - " + ProjDesc)
'ActiveWorkbook.SendMail Recipients:="user", Subject:=("Project Initialization Form - " + ProjDesc)
'End sending E-Mail to Accounting
MyWord.Documents.Close (MyDoc)
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Windows("IPB Database.xls").Activate
End Sub
Any help would be great!
The macro puts all of the entered information into excel and then I have the macro open word to fill auto fill a form. I got as far as opening the docuemnt from the excel, but I keep getting an error that a "document is not open" to put the collected info into the form. Below is the code. I then will send a copy, by e-mail, to accounting. This all worked fine until we updated our documents into word.
Private Sub SendPI_Form()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim MyWord As Word.Application
Set MyWord = CreateObject("Word.Application")
MyDoc = "P:\Office Tools\Administrative\Forms\Office 2003\Kansas City\Project Initialization Form.doc"
MyWord.Documents.Open (MyDoc)
MyWord.Visible = True
'I am stuck here
Windows("Project Initialization Form.doc").Activate
ActiveDocument.Bookmarks("RequestBy").Select
Selection.TypeText Text:="208"
ActiveDocument.Bookmarks("Date").Select
Selection.TypeText Text:=MonthName(Month(Date)) & " " & Day(Date) & " , " & Year(Date)
If NewProj.Value = True Then
ActiveSheet.OLEObjects("NewProject").Object.Value = True
End If
ActiveDocument.Bookmarks("ProjectNo").Select
Selection.TypeText Text:=IntlProjBlng.ProjNo
ActiveDocument.Bookmarks("ProjectDesc").Select
Selection.TypeText Text:=IntlProjBlng.ProjDesc
ActiveDocument.Bookmarks("PhaseNo").Select
Selection.TypeText Text:=IntlProjBlng.PhsNo
ActiveDocument.Bookmarks("PhaseDesc").Select
Selection.TypeText Text:=IntlProjBlng.PhsDesc
ActiveDocument.Bookmarks("IntOwner").Select
Selection.TypeText Text:=IntlProjBlng.IntOwnr
ActiveDocument.Bookmarks("RFCNo").Select
Selection.TypeText Text:=IntlProjBlng.RFCNo
ActiveDocument.Bookmarks("BillingType").Select
Selection.TypeText Text:=IntlProjBlng.BlngType
ActiveDocument.Bookmarks("BudgetAmount").Select
Selection.TypeText Text:=IntlProjBlng.FeeBud
ActiveDocument.Bookmarks("ProjectDate").Select
Selection.TypeText Text:=IntlProjBlng.InitDate
ActiveDocument.Bookmarks("InvVerb").Select
Selection.TypeText Text:=IntlProjBlng.InvoiceTxt
'Send E-mail to Accounting
ActiveWorkbook.SendMail Recipients:="user", Subject:=("Project Initialization Form - " + ProjDesc)
'ActiveWorkbook.SendMail Recipients:="user", Subject:=("Project Initialization Form - " + ProjDesc)
'End sending E-Mail to Accounting
MyWord.Documents.Close (MyDoc)
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Windows("IPB Database.xls").Activate
End Sub
Any help would be great!