AOB
Registered User.
- Local time
- Today, 13:52
- Joined
- Sep 26, 2012
- Messages
- 621
Hi guys,
I have a function which exports some data to Excel, performs some work, and then attaches the final report to an e-mail. All works fine apart from one small piece which used to work, but doesn't now, and I can't figure out why?
As a result of various temporary columns being added / removed (for formulas to determine scope etc.), the main sheet ends up scrolled to the bottom of the used range. Before I attach it to the e-mail, I want to scroll the sheet back to the top-left corner (A1).
I was using this :
It worked up until this week, when I had to make some changes to the rest of the code to refine the output. Now, when it hits the ".ScrollRow = 1" line, I get RTE 91 :
I don't understand quite why (this particular piece of code remains unchanged from before)
Any suggestions on how I can get the sheet to scroll to the top-left before I save it? (Such that, when subsequently attached to the e-mail, the recipient will open the workbook at the top-left cell and not sacrolled to the bottom)
Thanks!
Al
I have a function which exports some data to Excel, performs some work, and then attaches the final report to an e-mail. All works fine apart from one small piece which used to work, but doesn't now, and I can't figure out why?
As a result of various temporary columns being added / removed (for formulas to determine scope etc.), the main sheet ends up scrolled to the bottom of the used range. Before I attach it to the e-mail, I want to scroll the sheet back to the top-left corner (A1).
I was using this :
Code:
Public appExcel As Object ' Excel Application object (late-bound)
....
Dim objWorksheet As Object ' Excel Worksheet object (late-bound)
....
objWorksheet.Activate
With appExcel
With .ActiveWindow
.ScrollRow = 1
.ScrollColumn = 1
End With
End With
It worked up until this week, when I had to make some changes to the rest of the code to refine the output. Now, when it hits the ".ScrollRow = 1" line, I get RTE 91 :
Error 91: Object variable or With block variable not set
I don't understand quite why (this particular piece of code remains unchanged from before)
Any suggestions on how I can get the sheet to scroll to the top-left before I save it? (Such that, when subsequently attached to the e-mail, the recipient will open the workbook at the top-left cell and not sacrolled to the bottom)
Thanks!
Al