Newbie question

Faecon

New Member
Joined
Nov 17, 2017
Messages
4
I had this code working on a previous excel version

ActiveWorkbook.SaveAs filename:=Path & "SA-" & FileName1 & "-" & DATES & FileExtStr = ".xls": FileFormatNum = 56


now I get an error. Can anybody help me ?

Greets
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi Faecon and welcome to the board.

What Excel version did it work on and what Excel version do you have now?
Perhaps also if you were to post the rest of the code it might help!
 
Last edited:
Upvote 0
The previous version I don't know , now it is excel 2016.

It saves the file, but as false.xlsm . The file where the save action is in, is also a xlsm file.
What I want is to save a file in a map "archief" with the name SA-various name - date.xls

ActiveWorkbook.SaveAs filename:=Path & "SA-" & FileName1 & "-" & DATES & FileExtStr = ".xls": FileFormatNum = 56
ActiveWorkbook.Save
 
Upvote 0
Unless you supply all your code as requested by S.H.A.D.O. it's very difficult to tell, but try
Code:
ActiveWorkbook.SaveAs fileName:=path & "SA-" & FileName1 & "-" & DATES, FileFormat:=56
 
Upvote 0
this is the code :
Code:
Public telleraanwezig As Boolean
Function IsFileOpen(filename As String)

    Dim filenum As Integer, errnum As Integer
    On Error Resume Next   ' Turn error checking off.
    filenum = FreeFile()   ' Get a free file number.
    ' Attempt to open the file and lock it.
    Open filename For Input Lock Read As #filenum
    Close filenum          ' Close the file.
    errnum = Err           ' Save the error number that occurred.
    On Error GoTo 0        ' Turn error checking back on.
     'Check to see which error occurred.
    Select Case errnum
        ' No error occurred.
        ' File is NOT already open by another user.
        Case 0
         IsFileOpen = False
        ' Error number for "Permission Denied."
        ' File is already opened by another user.
        Case 70
            IsFileOpen = True
      ' Another error occurred.
       Case Else
           Error errnum
    End Select
 End Function
Sub fileopen()
If IsFileOpen("G:\path and file name.xls") Then
       MsgBox "De database is in gebruik. Gelieve deze eerst te sluiten"
        ActiveWindow.Close
    End If
End Sub
Sub invoer()
'zorgt ervoor dat de compatibiliteitsmodus niet opkomt
Application.DisplayAlerts = False
telleraanwezig = False
'opslaan en opslaan als zit geblokkeerd in thisworkbook
'
' invoer Macro
'
If IsFileOpen("path and file name 2") Then
       MsgBox "De database is in gebruik. Gelieve deze eerst te sluiten"
        ActiveWindow.Close
    End If
 
    Workbooks.Open filename:="path and file name"
    Rows("5:5").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Rows("8:8").Select
    Selection.Copy
    Rows("5:7").Select
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A8").Select
    Selection.AutoFill Destination:=Range("A5:A8"), Type:=xlFillDefault
    Range("A5:A8").Select
    
   
    
    Windows("invoeren storingsanalyse.xlsm").Activate
    Range("F10").Select
    Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("L5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
  
    
    Windows("invoeren storingsanalyse.xlsm").Activate
    Range("B6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("C5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
    Windows("invoeren storingsanalyse.xlsm").Activate
    Range("B5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("H5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
    
    Windows("invoeren storingsanalyse.xlsm").Activate
    Range("A13:E13").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("I5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Windows("invoeren storingsanalyse.xlsm").Activate
    Range("H5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("E5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
    Windows("invoeren storingsanalyse.xlsm").Activate
    Range("H6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("F5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
   ' Windows("invoeren storingsanalyse.xlsm").Activate
    'Range("H7").Select
    'Application.CutCopyMode = False
    'Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("K5").Select
    ActiveCell.FormulaR1C1 = "Nog te bekijken"
    
    'Range("K5").Select
    'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
     '   :=False, Transpose:=False
        
    Windows("invoeren storingsanalyse.xlsm").Activate
    Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Database storingsanalyses.xls").Activate
    Range("B5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
             
    
    Dim Path As String
    Dim FileName1 As String
'    Dim FileName2 As String
    Dim file As String
    Windows("invoeren storingsanalyse.xlsm").Activate
    DATES = Format(Range("B6"), "dd-mm-yyyy")
    Path = "file path here"
    FileName1 = Range("B5")
    file = "SA-" & FileName1 & "-" & DATES & ".xls"

      Windows("Database storingsanalyses.xls").Activate
      Range("J5").Select
      ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
            Address:="file path" & file, _
            TextToDisplay:="Link", _
            SubAddress:="" & CStr(LRowC), _
            ScreenTip:="" & CStr(LRowC)
            
   
     
           
    Range("P5").Select
    Application.CutCopyMode = False
    Selection.AutoFill Destination:=Range("P5:P7"), Type:=xlFillDefault
    Range("P5:P7").Select
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 6
    ActiveSheet.Range("$A$4:$L$1111").AutoFilter Field:=9, Criteria1:="="
    Rows("6:1113").Select
    Range("F7").Activate
    Selection.Delete Shift:=xlUp
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 9
    ActiveSheet.Range("$A$4:$L$1110").AutoFilter Field:=9
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    ActiveWindow.SmallScroll Down:=-9
    Range("A1:L3").Select
    
    telleraanwezig = True
    ActiveWorkbook.Save
    ActiveWindow.Close
    telleraanwezig = False
    
    
    'Doorsturen knop verwijderen voor het als nieuw bestand wordt opgeslaan
    
    ActiveSheet.Shapes("Doorsturen").Delete
    
   
       'Slaat het bestand op als
       telleraanwezig = True
       ActiveWorkbook.SaveAs filename:=Path & "SA-" & FileName1 & "-" & DATES & FileExtStr = ".xls": FileFormatNum = 56
        telleraanwezig = False
       'Slaat het bestand op
       telleraanwezig = True
       ActiveWorkbook.Save
       telleraanwezig = False
             
       'Print de file in het lokaal van LVC, maar zet daarna de standaardprinter terug
       Dim STDprinter As String
        STDprinter = Application.ActivePrinter
        ActiveSheet.PrintOut ActivePrinter:="\\SRPGEN23055\PR251419"
        Application.ActivePrinter = STDprinter
      'Opent outlook en verzend het invoer bestand
            
    With CreateObject("Outlook.Application")
x = .GetNamespace("MAPI").GetDefaultFolder(6).Items.Count
End With
   With CreateObject("Outlook.Application").createitem(0)
.to = "somepeople@someplace.com"

.Subject = "Storingsanalyse Processing " & Range("B5")

.attachments.Add "file path" & file
.Send
Range("A1").Value = Range("A1").Value + 1
    ActiveWindow.Close
 End With

    
End Sub
 
Last edited by a moderator:
Upvote 0
Did you try my suggestion in post#4
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top