+ Reply to Thread
Results 1 to 3 of 3

The Print dialogue interferes with the following Macro code

Hybrid View

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    Amsterdam
    MS-Off Ver
    Excel 2010 (Windows) Excel 2011 (Mac)
    Posts
    30

    The Print dialogue interferes with the following Macro code

    Hi all,

    Another question here. I have a MACRO that combines a "save as" command with a command to export specific data to another sheet. However, the "save as" dialogue box seems to interfere with the rest of the MACRO. Excel tries to continue when it should basically WAIT untill the saving has been done.

    How should I alter my code so that it doesn't crash anymore?

    Hope you can help. Thanks in advance!

    Sub EXPORT_Factuur_naar_admin_en_SAVE()
    
    'Show Message box'
    
    Dim nResult As Long
        nResult = MsgBox( _
        Prompt:="Zijn alle posten naar behoren ingevoerd en sluit de financiele data aan bij de organisatiegegevens? Zo ja, dan wordt dit overzicht geprint en wordt de hoofdgegevens van deze factuur digitaal opgeslagen. ", _
        Buttons:=vbYesNo)
        If nResult = vbNo Then
        Exit Sub
        End If
        
    'Save the file'
       Application.Dialogs(xlDialogSaveAs).Show
    
    'THIS IS WHERE THE PROBLEM OCCURS'
    
    'select data from this sheet and paste in the next sheet'
    Range("J20:J27").Select
        Application.CutCopyMode = False
        Selection.Copy
    Sheets("Betalingsadmin.").Select
    Range("B1000").End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=True
    
     
     'select proper sheet'
     Sheets("Factuur").Select
    
    End Sub

  2. #2
    Registered User
    Join Date
    06-28-2011
    Location
    New Delhi India
    MS-Off Ver
    Excel 2003 ,2007
    Posts
    23

    Re: The Print dialogue interferes with the following Macro code

    Try this and let me know ...

     
    Sub EXPORT_Factuur_naar_admin_en_SAVE()
    
    'Show Message box'
    
        Dim nResult As Long
        
        nResult = MsgBox( _
        Prompt:="Zijn alle posten naar behoren ingevoerd en sluit de financiele data aan bij de organisatiegegevens? Zo ja, dan wordt dit overzicht geprint en wordt de hoofdgegevens van deze factuur digitaal opgeslagen. ", _
        Buttons:=vbYesNo)
        
        If nResult = vbNo Then
            Exit Sub
        End If
        
        'Save the file'
       Application.Dialogs(xlDialogSaveAs).Show
    
        'THIS IS WHERE THE PROBLEM OCCURS'
    
        'select data from this sheet and paste in the next sheet'
        Range("J20:J27").Copy
        
        Sheets("sheet2").Range("B" & Sheets("sheet2").Range("B1000").End(xlUp).Row + 1).Offset(0, -1).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=True
    
        Application.CutCopyMode = False
        'select proper sheet'
        Sheets("Factuur").Select
    
    End Sub
    Purushottam
    Excel, MS ACCESS 2007

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    Amsterdam
    MS-Off Ver
    Excel 2010 (Windows) Excel 2011 (Mac)
    Posts
    30

    Re: The Print dialogue interferes with the following Macro code

    Thanks! It got the job done!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1