LenaWood
asked on
Exported info doesn't show up on first page of header (word)
I have information exported from Access to a word document using the following code:
Private Sub cmdSaveAll_Click()
Dim WordObj As Word.Application
Dim db As DAO.Database
Dim rsInspectionReport As Recordset
Dim mystrSQL As String
Dim MyFolderPath As String
Dim InspReportName As String
Dim strSaveNamePath As String
Set WordObj = CreateObject("Word.applica tion")
Set db = CurrentDb
mystrSQL = "SELECT * FROM qryInspectionReportAll WHERE [InspNumber] =" & [Forms]![frmInspectionRepo rtMenu]![t xtIDNumber ]
Set rsInspectionReport = db.OpenRecordset(mystrSQL)
With WordObj
.Visible = True
rsInspectionReport.MoveLas t
rsInspectionReport.MoveFir st
Do Until rsInspectionReport.EOF = True
.Documents.Add ("\\rdc1\surety\surety reviews\suretyreview.dot")
If Not IsNull(rsInspectionReport! InspNumber ) Then
.ActiveDocument.Bookmarks( "InspNum") .Range.Ins ertAfter rsInspectionReport![InspNu mber]
End If
If Not IsNull(rsInspectionReport! Agency) Then
.ActiveDocument.Bookmarks( "Agency"). Range.Inse rtAfter rsInspectionReport![Agency ]
End If
If Not IsNull(rsInspectionReport! ExternalCo ntrolNumbe r) Then
.ActiveDocument.Bookmarks( "ControlNu m").Range. InsertAfte r rsInspectionReport![Extern alControlN umber]
End If
If Not IsNull(rsInspectionReport! ISDate) Then
.ActiveDocument.Bookmarks( "IStartDat e").Range. InsertAfte r rsInspectionReport![ISDate ]
End If
If Not IsNull(rsInspectionReport! IEDate) Then
.ActiveDocument.Bookmarks( "IEndDate" ).Range.In sertAfter rsInspectionReport![IEDate ]
End If
If Not IsNull(rsInspectionReport! Inspection Title) Then
.ActiveDocument.Bookmarks( "ITitle"). Range.Inse rtAfter rsInspectionReport![Inspec tionTitle]
End If
If Not IsNull(rsInspectionReport! FindingNum ) Then
.ActiveDocument.Bookmarks( "FNumber") .Range.Ins ertAfter rsInspectionReport![Findin gNum]
End If
If Not IsNull(rsInspectionReport! FDate) Then
.ActiveDocument.Bookmarks( "FDate").R ange.Inser tAfter rsInspectionReport![FDate]
End If
If Not IsNull(rsInspectionReport! Reviewer) Then
.ActiveDocument.Bookmarks( "Reviewer" ).Range.In sertAfter rsInspectionReport![Review er]
End If
If Not IsNull(rsInspectionReport! AreaOfInte rest) Then
.ActiveDocument.Bookmarks( "Interest" ).Range.In sertAfter rsInspectionReport![AreaOf Interest]
End If
If Not IsNull(rsInspectionReport! FactorsAff ecting) Then
.ActiveDocument.Bookmarks( "Factors") .Range.Ins ertAfter rsInspectionReport![Factor sAffecting ]
End If
If Not IsNull(rsInspectionReport! Finding) Then
.ActiveDocument.Bookmarks( "Finding") .Range.Ins ertAfter rsInspectionReport![Findin g]
End If
If Not IsNull(rsInspectionReport! Reference) Then
.ActiveDocument.Bookmarks( "Reference ").Range.I nsertAfter rsInspectionReport![Refere nce]
End If
If Not IsNull(rsInspectionReport! Recommenda tion) Then
.ActiveDocument.Bookmarks( "Recommend ").Range.I nsertAfter rsInspectionReport![Recomm endation]
End If
If Not IsNull(rsInspectionReport! Category) Then
.ActiveDocument.Bookmarks( "Category" ).Range.In sertAfter rsInspectionReport![Catego ry]
End If
If Not IsNull(rsInspectionReport! Responsibi lity) Then
.ActiveDocument.Bookmarks( "Resp").Ra nge.Insert After rsInspectionReport![Respon sibility]
End If
If Not IsNull(rsInspectionReport! Acknowledg edBy) Then
.ActiveDocument.Bookmarks( "Acknow"). Range.Inse rtAfter rsInspectionReport![Acknow ledgedBy]
End If
If Not IsNull(rsInspectionReport! ClosedDate ) Then
.ActiveDocument.Bookmarks( "CDate").R ange.Inser tAfter rsInspectionReport![Closed Date]
End If
If Not IsNull(rsInspectionReport! MgrAssess) Then
.ActiveDocument.Bookmarks( "MgrAss"). Range.Inse rtAfter rsInspectionReport![MgrAss ess]
End If
If Not IsNull(rsInspectionReport! CorrActPla n) Then
.ActiveDocument.Bookmarks( "CorrAct") .Range.Ins ertAfter rsInspectionReport![CorrAc tPlan]
End If
If Not IsNull(rsInspectionReport! Notes) Then
.ActiveDocument.Bookmarks( "Notes").R ange.Inser tAfter rsInspectionReport![Notes]
End If
If Not IsNull(rsInspectionReport! VerifiedBy ) Then
.ActiveDocument.Bookmarks( "VerifiedB y").Range. InsertAfte r rsInspectionReport![Verifi edBy]
End If
If Not IsNull(rsInspectionReport! ReportAge) Then
.ActiveDocument.Bookmarks( "ReportAge ").Range.I nsertAfter rsInspectionReport![Report Age]
End If
If Not IsNull(rsInspectionReport! MyECD) Then
.ActiveDocument.Bookmarks( "FindECD") .Range.Ins ertAfter rsInspectionReport![MyECD]
End If
MyFolderPath = "\\rdc1\surety\surety reviews\inspection reports\Inspection " & rsInspectionReport!InspNum ber
If Dir(MyFolderPath, vbDirectory) = "" Then
MkDir MyFolderPath
Else
End If
InspReportName = rsInspectionReport!Finding Num
.ActiveDocument.SaveAs MyFolderPath & "\" & InspReportName
.ActiveDocument.Close
rsInspectionReport.MoveNex t
Loop
End With
rsInspectionReport.Close
Set rsInspectionReport = Nothing
WordObj.Quit
End Sub
Private Sub cmdSaveSingle_Click()
Dim WordObj As Word.Application
Dim db As DAO.Database
Dim rsInspectionReport As Recordset
Dim mystrSQL As String
Dim MyFolderPath As String
Dim InspReportName As String
Dim strSaveNamePath As String
Set WordObj = CreateObject("Word.applica tion")
Set db = CurrentDb
mystrSQL = "SELECT * FROM qryInspectionReportAll WHERE [RecordID] =" & [Forms]![frmInspectionRepo rtMenu]![t xtIDNumber ]
Set rsInspectionReport = db.OpenRecordset(mystrSQL)
With WordObj
.Visible = True
rsInspectionReport.MoveLas t
rsInspectionReport.MoveFir st
Do Until rsInspectionReport.EOF = True
.Documents.Add ("\\rdc1\surety\surety reviews\suretyreview.dot")
If Not IsNull(rsInspectionReport! InspNumber ) Then
.ActiveDocument.Bookmarks( "InspNum") .Range.Ins ertAfter rsInspectionReport![InspNu mber]
End If
If Not IsNull(rsInspectionReport! Agency) Then
.ActiveDocument.Bookmarks( "Agency"). Range.Inse rtAfter rsInspectionReport![Agency ]
End If
If Not IsNull(rsInspectionReport! ExternalCo ntrolNumbe r) Then
.ActiveDocument.Bookmarks( "ControlNu m").Range. InsertAfte r rsInspectionReport![Extern alControlN umber]
End If
If Not IsNull(rsInspectionReport! ISDate) Then
.ActiveDocument.Bookmarks( "IStartDat e").Range. InsertAfte r rsInspectionReport![ISDate ]
End If
If Not IsNull(rsInspectionReport! IEDate) Then
.ActiveDocument.Bookmarks( "IEndDate" ).Range.In sertAfter rsInspectionReport![IEDate ]
End If
If Not IsNull(rsInspectionReport! Inspection Title) Then
.ActiveDocument.Bookmarks( "ITitle"). Range.Inse rtAfter rsInspectionReport![Inspec tionTitle]
End If
If Not IsNull(rsInspectionReport! FindingNum ) Then
.ActiveDocument.Bookmarks( "FNumber") .Range.Ins ertAfter rsInspectionReport![Findin gNum]
End If
If Not IsNull(rsInspectionReport! FDate) Then
.ActiveDocument.Bookmarks( "FDate").R ange.Inser tAfter rsInspectionReport![FDate]
End If
If Not IsNull(rsInspectionReport! Reviewer) Then
.ActiveDocument.Bookmarks( "Reviewer" ).Range.In sertAfter rsInspectionReport![Review er]
End If
If Not IsNull(rsInspectionReport! AreaOfInte rest) Then
.ActiveDocument.Bookmarks( "Interest" ).Range.In sertAfter rsInspectionReport![AreaOf Interest]
End If
If Not IsNull(rsInspectionReport! FactorsAff ecting) Then
.ActiveDocument.Bookmarks( "Factors") .Range.Ins ertAfter rsInspectionReport![Factor sAffecting ]
End If
If Not IsNull(rsInspectionReport! Finding) Then
.ActiveDocument.Bookmarks( "Finding") .Range.Ins ertAfter rsInspectionReport![Findin g]
End If
If Not IsNull(rsInspectionReport! Reference) Then
.ActiveDocument.Bookmarks( "Reference ").Range.I nsertAfter rsInspectionReport![Refere nce]
End If
If Not IsNull(rsInspectionReport! Recommenda tion) Then
.ActiveDocument.Bookmarks( "Recommend ").Range.I nsertAfter rsInspectionReport![Recomm endation]
End If
If Not IsNull(rsInspectionReport! Category) Then
.ActiveDocument.Bookmarks( "Category" ).Range.In sertAfter rsInspectionReport![Catego ry]
End If
If Not IsNull(rsInspectionReport! Responsibi lity) Then
.ActiveDocument.Bookmarks( "Resp").Ra nge.Insert After rsInspectionReport![Respon sibility]
End If
If Not IsNull(rsInspectionReport! Acknowledg edBy) Then
.ActiveDocument.Bookmarks( "Acknow"). Range.Inse rtAfter rsInspectionReport![Acknow ledgedBy]
End If
If Not IsNull(rsInspectionReport! ClosedDate ) Then
.ActiveDocument.Bookmarks( "CDate").R ange.Inser tAfter rsInspectionReport![Closed Date]
End If
If Not IsNull(rsInspectionReport! MgrAssess) Then
.ActiveDocument.Bookmarks( "MgrAss"). Range.Inse rtAfter rsInspectionReport![MgrAss ess]
End If
If Not IsNull(rsInspectionReport! CorrActPla n) Then
.ActiveDocument.Bookmarks( "CorrAct") .Range.Ins ertAfter rsInspectionReport![CorrAc tPlan]
End If
If Not IsNull(rsInspectionReport! Notes) Then
.ActiveDocument.Bookmarks( "Notes").R ange.Inser tAfter rsInspectionReport![Notes]
End If
If Not IsNull(rsInspectionReport! VerifiedBy ) Then
.ActiveDocument.Bookmarks( "VerifiedB y").Range. InsertAfte r rsInspectionReport![Verifi edBy]
End If
If Not IsNull(rsInspectionReport! ReportAge) Then
.ActiveDocument.Bookmarks( "ReportAge ").Range.I nsertAfter rsInspectionReport![Report Age]
End If
If Not IsNull(rsInspectionReport! MyECD) Then
.ActiveDocument.Bookmarks( "FindECD") .Range.Ins ertAfter rsInspectionReport![MyECD]
End If
MyFolderPath = "\\rdc1\surety\surety reviews\inspection reports\Inspection " & rsInspectionReport!InspNum ber
If Dir(MyFolderPath, vbDirectory) = "" Then
MkDir MyFolderPath
Else
End If
InspReportName = rsInspectionReport!Finding Num
.ActiveDocument.SaveAs MyFolderPath & "\" & InspReportName
.ActiveDocument.Close
rsInspectionReport.MoveNex t
Loop
End With
rsInspectionReport.Close
Set rsInspectionReport = Nothing
WordObj.Quit
End Sub
I am not sure if this is an existing problem or one that just started, but the information that is in the header of the word document doesn't show up on the first page. If there is more than one page to the document, the information shows up on the following pages (in the header).
I don't think this is a problem with my code, but a setting in Word...I just don't know what the setting would be or where I would find it to change it. Please help!
Lena
Private Sub cmdSaveAll_Click()
Dim WordObj As Word.Application
Dim db As DAO.Database
Dim rsInspectionReport As Recordset
Dim mystrSQL As String
Dim MyFolderPath As String
Dim InspReportName As String
Dim strSaveNamePath As String
Set WordObj = CreateObject("Word.applica
Set db = CurrentDb
mystrSQL = "SELECT * FROM qryInspectionReportAll WHERE [InspNumber] =" & [Forms]![frmInspectionRepo
Set rsInspectionReport = db.OpenRecordset(mystrSQL)
With WordObj
.Visible = True
rsInspectionReport.MoveLas
rsInspectionReport.MoveFir
Do Until rsInspectionReport.EOF = True
.Documents.Add ("\\rdc1\surety\surety reviews\suretyreview.dot")
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
MyFolderPath = "\\rdc1\surety\surety reviews\inspection reports\Inspection " & rsInspectionReport!InspNum
If Dir(MyFolderPath, vbDirectory) = "" Then
MkDir MyFolderPath
Else
End If
InspReportName = rsInspectionReport!Finding
.ActiveDocument.SaveAs MyFolderPath & "\" & InspReportName
.ActiveDocument.Close
rsInspectionReport.MoveNex
Loop
End With
rsInspectionReport.Close
Set rsInspectionReport = Nothing
WordObj.Quit
End Sub
Private Sub cmdSaveSingle_Click()
Dim WordObj As Word.Application
Dim db As DAO.Database
Dim rsInspectionReport As Recordset
Dim mystrSQL As String
Dim MyFolderPath As String
Dim InspReportName As String
Dim strSaveNamePath As String
Set WordObj = CreateObject("Word.applica
Set db = CurrentDb
mystrSQL = "SELECT * FROM qryInspectionReportAll WHERE [RecordID] =" & [Forms]![frmInspectionRepo
Set rsInspectionReport = db.OpenRecordset(mystrSQL)
With WordObj
.Visible = True
rsInspectionReport.MoveLas
rsInspectionReport.MoveFir
Do Until rsInspectionReport.EOF = True
.Documents.Add ("\\rdc1\surety\surety reviews\suretyreview.dot")
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
If Not IsNull(rsInspectionReport!
.ActiveDocument.Bookmarks(
End If
MyFolderPath = "\\rdc1\surety\surety reviews\inspection reports\Inspection " & rsInspectionReport!InspNum
If Dir(MyFolderPath, vbDirectory) = "" Then
MkDir MyFolderPath
Else
End If
InspReportName = rsInspectionReport!Finding
.ActiveDocument.SaveAs MyFolderPath & "\" & InspReportName
.ActiveDocument.Close
rsInspectionReport.MoveNex
Loop
End With
rsInspectionReport.Close
Set rsInspectionReport = Nothing
WordObj.Quit
End Sub
I am not sure if this is an existing problem or one that just started, but the information that is in the header of the word document doesn't show up on the first page. If there is more than one page to the document, the information shows up on the following pages (in the header).
I don't think this is a problem with my code, but a setting in Word...I just don't know what the setting would be or where I would find it to change it. Please help!
Lena
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am a bit confused. Is the first page different , but in the wrong way? If so, what is actually wrong with the page.
Note that you can also differentiate between what headers display by using page numbers or field calculations that depend on page numbers
{If {Page} < {Numpages} "Continued"}
Note that you can also differentiate between what headers display by using page numbers or field calculations that depend on page numbers
{If {Page} < {Numpages} "Continued"}
ASKER
I figured out why this wasn't working.
When I made it so that my headers were not the same, I didn't take into account that I couldn't have two bookmarks named the same in two different places. When I wanted the headers to be different, then the table on my first page header no longer had working bookmarks.
I am giving them new bookmark names, changing my code in the database and everything seems to be working great!
I will award the points to you for heading me in the right direction about the header button being chekced. Without that information I wouldn't have realized that I actually had two different tables and needed to create new book marks.
Thanks for giving me some insight!
Lena
When I made it so that my headers were not the same, I didn't take into account that I couldn't have two bookmarks named the same in two different places. When I wanted the headers to be different, then the table on my first page header no longer had working bookmarks.
I am giving them new bookmark names, changing my code in the database and everything seems to be working great!
I will award the points to you for heading me in the right direction about the header button being chekced. Without that information I wouldn't have realized that I actually had two different tables and needed to create new book marks.
Thanks for giving me some insight!
Lena
Thanks. I was wondering how you had designed it.
ASKER
Any other suggestions?
Lena