Can anyone please help.
I have moved my Access database from one machine to another. All the references in my code are the same.
Here is my code for a command using word. Access cant see the reference in line - Set objWord = New Word.Application
I have tried to set the reference to word but with no joy!
'This sub opens, prints and saves a document. It also populates a bookmark based on a text box in your form
'Dim objects and variables
Dim objWord As Object
Dim strFile As String
Dim strSaveAsFile As String
'Grab the Document name This line changes if database or references are moved!
strFile = "C:\Andy's Work\Risk Assessment Database\Project Work\Temp For Workplace risk Assessment.doc"
'Launch word
Set objWord = New Word.Application
With objWord
'Open the file
.Documents.Open FileName:=Chr(34) & strFile & Chr(34)
'Make it visible
.Visible = True
'Populate a bookmark
.ActiveDocument.Bookmarks.Item("Ref"
.Range.Text = " " & Me.[Assessment Refference Number] 'this is a textbox
.ActiveDocument.Bookmarks.Item("Ref1"
.Range.Text = " " & Me.[Combo58] 'this is a textbox
.ActiveDocument.Bookmarks.Item("Ref2"
.Range.Text = " " & Me.[Department] 'this is a textbox
.ActiveDocument.Bookmarks.Item("Ref3"
.Range.Text = " " & Me.[Combo14] 'this is a textbox
.ActiveDocument.Bookmarks.Item("Ref4"
.Range.Text = " " & Me.[Location] 'this is a textbox
.ActiveDocument.Bookmarks.Item("Ref5"
.Range.Text = " " & Me.[Assessment Date] 'this is a textbox
.Application.Options.PrintBackground = False
.ActiveDocument.PrintOut
strSaveAsFile = Chr(34) & "C:\Andy's Work\Risk Assessment Database\Project Work\RAD Assessment Workplace\" & Me.[Assessment Refference Number] & Chr(34)
.ActiveDocument.SaveAs FileName:=strSaveAsFile
.Quit
End With
Set objWord = Nothing
End Sub
Help me please Im going mad!
Andy
I have moved my Access database from one machine to another. All the references in my code are the same.
Here is my code for a command using word. Access cant see the reference in line - Set objWord = New Word.Application
I have tried to set the reference to word but with no joy!
'This sub opens, prints and saves a document. It also populates a bookmark based on a text box in your form
'Dim objects and variables
Dim objWord As Object
Dim strFile As String
Dim strSaveAsFile As String
'Grab the Document name This line changes if database or references are moved!
strFile = "C:\Andy's Work\Risk Assessment Database\Project Work\Temp For Workplace risk Assessment.doc"
'Launch word
Set objWord = New Word.Application
With objWord
'Open the file
.Documents.Open FileName:=Chr(34) & strFile & Chr(34)
'Make it visible
.Visible = True
'Populate a bookmark
.ActiveDocument.Bookmarks.Item("Ref"
.ActiveDocument.Bookmarks.Item("Ref1"
.ActiveDocument.Bookmarks.Item("Ref2"
.ActiveDocument.Bookmarks.Item("Ref3"
.ActiveDocument.Bookmarks.Item("Ref4"
.ActiveDocument.Bookmarks.Item("Ref5"
.Application.Options.PrintBackground = False
.ActiveDocument.PrintOut
strSaveAsFile = Chr(34) & "C:\Andy's Work\Risk Assessment Database\Project Work\RAD Assessment Workplace\" & Me.[Assessment Refference Number] & Chr(34)
.ActiveDocument.SaveAs FileName:=strSaveAsFile
.Quit
End With
Set objWord = Nothing
End Sub
Help me please Im going mad!
Andy