G
Guest
Hiya, I posted this query a while back and got some helpful tips from TC. Have been a way for a while so I thought I'd re-post it with further detail
I am running a procedure in Access that will create and open 4 recordsets... it will then copy a master Excel workbook to a target file, open this target file and go through 4 different sheets copying the 4 recordsets respectively. It then also emails the file (using the XLWorkbook.SendMail method) to an address held in a variable
I managed to get this to work beautifully - but only by making Excel visible. Here is the relevant part of my code
FileCopy Master, TargetFil
Set XLWorkbook = GetObject(TargetFile
With XLWorkboo
.Application.Visible = True '/////////////////////////////////////////////////////////
.Parent.windows(1).Visible = True '/////////////////////////////////////////////////////////
.Sheets(2).Range("A9").CopyFromRecordset rstre
.Sheets(2).Range("A2") = "Returned to host since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
.Sheets(3).Range("A9").CopyFromRecordset rstpreo
.Sheets(3).Range("A2") = "Returned to host since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
.Sheets(4).Range("A8").CopyFromRecordset rstb
.Sheets(4).Range("A2") = "Returned to host since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
.Sheets(5).Range("A8").CopyFromRecordset rsti
.Sheets(5).Range("A2") = "Discharged since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
End Wit
I want the procedure to run without showing Excel on screen (I want to have a form open in Access saying, "Please wait whilst the report is emailed" - or something). However, by removing the code (lines above with loads of ///// symbols) that makes Excel visible, I get the following error
run-time error '-2147417851 (80010105)
Method 'CopyFromRecordset' of object 'Range' failed
Does anybody know how I can run this part of the procedure without Excel showing up on screen
Thank you for any suggestions
TC, thanks for your help earlier - it was very useful and I am using the application quit method that you suggested. I hope the info I have given here will make this problem clearer to you
Muchas! Basil
I am running a procedure in Access that will create and open 4 recordsets... it will then copy a master Excel workbook to a target file, open this target file and go through 4 different sheets copying the 4 recordsets respectively. It then also emails the file (using the XLWorkbook.SendMail method) to an address held in a variable
I managed to get this to work beautifully - but only by making Excel visible. Here is the relevant part of my code
FileCopy Master, TargetFil
Set XLWorkbook = GetObject(TargetFile
With XLWorkboo
.Application.Visible = True '/////////////////////////////////////////////////////////
.Parent.windows(1).Visible = True '/////////////////////////////////////////////////////////
.Sheets(2).Range("A9").CopyFromRecordset rstre
.Sheets(2).Range("A2") = "Returned to host since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
.Sheets(3).Range("A9").CopyFromRecordset rstpreo
.Sheets(3).Range("A2") = "Returned to host since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
.Sheets(4).Range("A8").CopyFromRecordset rstb
.Sheets(4).Range("A2") = "Returned to host since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
.Sheets(5).Range("A8").CopyFromRecordset rsti
.Sheets(5).Range("A2") = "Discharged since " & Format([Forms]![External Reporting]![txtstdate],
"dddd d mmmm yyyy"
End Wit
I want the procedure to run without showing Excel on screen (I want to have a form open in Access saying, "Please wait whilst the report is emailed" - or something). However, by removing the code (lines above with loads of ///// symbols) that makes Excel visible, I get the following error
run-time error '-2147417851 (80010105)
Method 'CopyFromRecordset' of object 'Range' failed
Does anybody know how I can run this part of the procedure without Excel showing up on screen
Thank you for any suggestions
TC, thanks for your help earlier - it was very useful and I am using the application quit method that you suggested. I hope the info I have given here will make this problem clearer to you
Muchas! Basil