Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    150

    Angry Unanswered: lines of code not executing??

    Hi,

    i have this VBA macro on an excel sheet. Here is the code that gives me trouble:

    ------------------------------------------------------------------------------------

    Sub SaveMe2()

    With Application
    .DisplayAlerts = True
    .ScreenUpdating = True
    End With

    Dim fname1 As String
    Dim fname2 As String

    ' Save as Range Name
    fname1 = Sheets("invoice").Range("N57")

    ' Save as user Input
    fname2 = InputBox("Please enter the target Filename", "Filename Entry")

    On Error Goto Error:

    With ActiveWorkbook
    .SaveAs Filename:="\\ADMIN\My Documents\Comptabilité\FactureClients\" & fname2 & ".xls"
    .SaveAs Filename:="C:\Documents and Settings\Mr.Crud\My Documents\E-Comm\Audio Occasion\Factures Clients" & fname2 & ".xls"
    End With

    ActiveWindow.SelectedSheets.PrintOut Copies:=3, Collate:=True

    Workbooks.Open Filename:="C:\Documents and Settings\Mr.Crud\My Documents\E-Comm\Audio Occasion\Test\Factures Clients.xls"

    Workbooks("" & fname2 & ".xls").Close True

    Error:

    End Sub

    -----------------------------------------------------------------------------------

    when i step into the code, it doesnt execute the last 2 commands ( the Workbooks.Open.... and the Workbooks.Close.... ) it just skips right over.

    anyone know why??

    I'm running this on Excel 2003, but the code was originally written on a Excel XP machine.

    Thanks!
    Cheers!

    Mr.Crud

    There are 10 kinds of people, ones that understand digital, others that dont

  2. #2
    Join Date
    Dec 2003
    Location
    San Diego, CA
    Posts
    153
    As long as the file exists, it should open.

    The second part should be:

    Workbooks(fname2).Close True

    And Display =Alerts & ScreenUpdating should be false at the beginning of the code and set to True at the end.

    I'll repost the entire code I gave you before if it will help.

    Smitty

  3. #3
    Join Date
    Nov 2003
    Posts
    150
    Hi again Smitty,

    The thing i dont get is that it runs fine on my computer, but not on the machine i designed this file for!!!

    When running the code one line at a time, it just skips right over the lines??!!!

    Workbooks(fname2).Close True line, i cant get it to work this way, i have to put in the rest.

    Is there a difference between Excel 2003 and XP that would cause this, such as a change in the commands???

    thanks for the reply!

    Cheers!
    Cheers!

    Mr.Crud

    There are 10 kinds of people, ones that understand digital, others that dont

  4. #4
    Join Date
    Dec 2003
    Location
    San Diego, CA
    Posts
    153
    Is there a difference between Excel 2003 and XP that would cause this, such as a change in the commands???
    Not that I'm aware of, but I could be wrong. I'd look at the Microsoft Knowledge Base and see if you get any answers there.

    Smitty

Posting Permissions

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