VBA - SaveAs hangs (2003 vs 2k ?)

M

mtrak

I've searched this forum and a bunch of microsoft docs and have no
found a solution to my problem, so I'm wondering if anyone here know
why this is happening:

My code below executes perfectly on my PC running Excel 2003. But whe
I attempt to run it on 2 other PCs, both running Excel 2000 for wha
it's worth, the code simply hangs at the "SaveAs" ... no error o
anything...

I don't know for sure whether it is version-related (2k v. 2003)..
just throwing that out there since this DOES WORK on my 2003 machine..
in fact I am out of ideas as to why this would happen.

Anyone seen anything like this?
Am I doing something wrong?
Any clues would be greatly appreciated

Thanks!
Mike

My code:




Private Sub SaveGraph()
Dim xExcelApp As New Excel.Application
Dim xWorkbk As Excel.Workbook
Dim xTempName As String
Dim xSaveName As String
Dim xPath As String

Set xWorkbk = xExcelApp.Workbooks.Add


' ===============================
'Create Graph Here
' ===============================

xPath = "C:\temp\"
xTempName = xPath & "test_graph.xls"

ChDir xPath

xSaveName = m_objExcelApp.GetSaveAsFilename( _
InitialFileName:=xTempName, _
FileFilter:="Microsoft Excel Workboo
(*.xls), *.xls")

MsgBox "saving..."
xWorkbk.SaveAs FileName:=xSaveName ' << dies here
MsgBox "saved!"



End Sub


[/FONT
 
T

TroyW

Mike,

Just taking some guesses.

Have you tried passing the filename by position, instead of by name.
xWorkbk.SaveAs xSaveName

Do you have the application visible?
xExcelApp.Visible = True

I see you have another variable: m_objExcelApp
Where is this defined. Is it visible?

Troy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top