Results 1 to 8 of 8

Thread: Code Crashes on WinXP

  1. #1

    Code Crashes on WinXP



    Register for a FREE account, and/
    or Log in to avoid these ads!

    And I can't figure out why!! I did ask this on MrExcel with no real response.

    Code:
    Sub SaveForImporting()
    ThisWorkbook.SaveAs "C:\MImport" & ".xls", FileFormat:=56
    ActiveWorkbook.Close False
    End Sub
    Help!! Thanks and Hi, Ken!

    Yes, I have rights to root.
    The file format is xlsm before saving. I don't *need* a macro-free workbook, I just need xls so the SQL that's going to use the data works right.
    Last edited by Anne Troy; 2012-01-20 at 07:51 PM.

  2. #2
    Code:
    Sub SaveForImporting()
    Dim strFileName As String
    strFileName = "MyBook"
    ThisWorkbook.SaveAs "C:\MImport\" & strFileName & ".xls", FileFormat:=56
    ActiveWorkbook.Close False
    End Sub
    Oops, just realised that you want to save to C:\ and file name is MImport.xls. I don't know why you can't do it. It works for me
    Last edited by eferrero; 2012-01-20 at 11:34 PM.

  3. #3
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,250
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Anne, I'm just booting up a VM running Windows XP. What version of Office are you running? 2007 or 2010? The code is called from an xlsm file, but trying to save in an xls format, is that right?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  4. #4
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,250
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Hmmm... have to ask... are you SURE you have rights to create files in the root of C:\ on your system? Like Ed, it's working fine for me as you posted.

    Maybe there is something else in the code that is causing a conflict, or the file is corrupt?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  5. #5
    Hi, Ken! Thanks and sorry for the delay. Yes. We have rights to C. Everything works perfectly. Except the error AFTER it saves the file. I'm saving as XLS extension. Don't care whether there's code in the file or not or what the *actual* file type is.

    Very weird.

    Code:
    Sub SaveToC()
    Application.DisplayAlerts = False
    If Len(Dir("C:\Users\", vbDirectory)) = 0 Then
    ThisWorkbook.SaveAs "C:\FLImport" & ".xls", FileFormat:= _
            xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
            , CreateBackup:=False
    ActiveWorkbook.Close False
    Else: MsgBox ("No Way!" & Chr(13) & "You are not on a virtual machine." & Chr(13) & Chr(13) & "Para nada!" & Chr(13) & "Tu no estas en una maquina virtual."), vbOKOnly
    End If
    
    Application.DisplayAlerts = False
    
    End Sub
    Hoping this forum takes code tags.

  6. #6
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,250
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Okay, so what is the error exactly? What line is highlighted?

    This code is now checking to make sure that the C:\Users folder doesn't exist, and tries to save the file as an xls if true. That's correct?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  7. #7
    Yes, but that doesn't matter. It crashed before that was there. We perform programming of a sort on virtual machines. The workbook is usually worked on the regular machine, saved to a network drive, opened on the virtual, saved to C. No matter how little or how much code is there, it crashes. So, it's not the code. It's gotta be something else. It's the usual "Microsoft Office Excel has encountered a problem and needs to close" and closes with the Send report button.

  8. #8
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,250
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Ohhh.... THAT error. Application Crash. I thought you meant just a Debug type.

    Hmmm... what kind of virtual machine? Hyper-V, VMWare, VirtualBox?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •