Results 1 to 8 of 8

The code have an error and do not run

Threaded View

torti111 The code have an error and do... 04-05-2017, 03:51 AM
Special-K Re: The code have an error... 04-05-2017, 04:52 AM
torti111 Re: The code have an error... 04-05-2017, 05:04 AM
Special-K Re: The code have an error... 04-05-2017, 05:16 AM
bakerman2 Re: The code have an error... 04-05-2017, 05:19 AM
torti111 Re: The code have an error... 04-05-2017, 05:32 AM
bakerman2 Re: The code have an error... 04-05-2017, 07:40 AM
torti111 Re: The code have an error... 04-05-2017, 08:25 AM
  1. #1
    Registered User
    Join Date
    08-27-2015
    Location
    Friedberg
    MS-Off Ver
    2010
    Posts
    68

    The code have an error and do not run

    Hi all,

    with the following the VBA should open a "save as" window in Folder G:\Shareplan\test_31686\Plan\07\
    The user should choose a subfolder for example G:\Shareplan\test_31686\Plan\07\test123\ to save the file.
    The filename should be contrib_per_payroll_check_ & Tag --> for example "contrib_per_payroll_check_170405.

    Could you please check what is wrong in my code?

    Private Sub Workbook_Open()
    
    
    Dim Pfad, Tag
    
    With ActiveDocument
        With Application.FileDialog(msoFileDialogFolderPicker)
            .AllowMultiSelect = False
            .InitialFileName = "G:\Shareplan\test_31686\Plan\07\"
            If .Show <> -1 Then MsgBox "No folder selected! Exiting sub...": Exit Sub
            mydir = .SelectedItems(1)
        End With
        Pfad = mydir & "\"
        Tag = Format("yymmdd")
        Application.DisplayAlerts = False
        .SaveAs Filename: .Name = contrib_per_payroll_check_ & Tag
        Application.DisplayAlerts = True
         
        .Close
    End With
    
    
    
    End Sub
    Kind regards,

    Thorsten
    Last edited by torti111; 04-05-2017 at 05:13 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need error handler code to avoid pivot table refreshing error if no data is available
    By adelkam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2015, 12:37 PM
  2. Need to add if error code to worksheet change event to stop a run-time error
    By KT99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2014, 03:10 PM
  3. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  4. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  5. [SOLVED] Getting Error 1004 Object or Application Defined Error - Code to rearrange data
    By BlazzedTroll in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-10-2013, 12:10 PM
  6. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  7. Error 424 Object Required Error when Using AddItem to ListBox Generated in Code
    By jclark419 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2010, 12:47 PM

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