LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Resume.xlw and closing workbook with VBA code.

Hi, all.

I'm an Access programmer working on a .mdb that creates an Excel
spreadsheet. After doing so, I need to open the worksheet, edit it to set
consistent heading formats, then close it. The spreadsheet creates
beautifully, and all of the formatting that I want is applied to it, but I
have two glitches when trying to close it:

1) The .Close command generates a "method not supported for this object"
error.
2) When I then try to close it manually, I get an error message that reads
"A file named 'RESUME.XLW' already exists in this location. Do you want to
replace it?

I've only done fairly simple macros in Excel, usually creating them with
recorder and making minor modifications, so I'm not familiar "resume.xlw".
Only found a couple of posts dealing with it when I searched here, and they
weren't much help.

The sub is below. Can anyone out there help?

Thanks,
Bruce

Sub SetSpreadsheetHeadings(forFilePath)
On Error GoTo SpreadsheetErr
'
' Sets headings for new spreadsheet.
'
Dim MyXL As Object

Set MyXL = CreateObject("Excel.Application")

With MyXL
.Workbooks.Open forFilePath

'I'd rather not make it visible at all, if I can do it that way.
.Application.Visible = True
.Parent.Windows(1).Visible = True

.Rows("1:1").Select
.Selection.Font.FontStyle = "Bold"
.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
.Selection.Borders(xlEdgeLeft).LineStyle = xlNone
.Selection.Borders(xlEdgeTop).LineStyle = xlNone
With .Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
.Selection.Borders(xlEdgeRight).LineStyle = xlNone
.Selection.Borders(xlInsideVertical).LineStyle = xlNone
With .Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
.Cells.Select
.Selection.Columns.AutoFit
.Columns("A:A").Select
.Selection.EntireColumn.Hidden = True

'Unhighlight rows left selected.
.Range("B2").Select

.Save
DoEvents

.Close 'Causes error.
End With

Set MyXL = Nothing

Exit Sub

SpreadsheetErr:
MsgBox "Error editing spreadsheet:" & vbCr & vbCr & _
"Error Code: " & Err.Number & vbCr & _
Err.Description, vbOKCritical, "Error!"
Err.Clear

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
close workbook without closing excel and stop recursive function chris Excel Discussion (Misc queries) 3 July 10th 06 08:23 PM
Opened Autosave but when closing workbook Autosave closes itself Ken Excel Worksheet Functions 0 October 29th 05 05:11 PM
Help with closing down a workbook?? Don Excel Worksheet Functions 1 May 9th 05 04:05 AM
prohibit closing a workbook Christophero Excel Discussion (Misc queries) 2 April 4th 05 05:54 PM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 08:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"