Dear Board,
Using some VBA code which I got from the Net, I am creating a New File/WorkBook from an Original File which has some sheets which are like Value Copies of the Original File for Distribution..
Now the problem I face is that these files are getting created in the format shown in the last two files..
Now everytime I have to open these files using the Open With Dialog Box though these are normal files with no VBA code or even any kind of Macros in it..
So how do I repair this error ?
Please find the code below which I am using to create these files from my Sheets...
Can someone please guide me on the same this code which I am using is not my own but I am working around it..
Thanks in advance
Warm Regards
all4excel
Using some VBA code which I got from the Net, I am creating a New File/WorkBook from an Original File which has some sheets which are like Value Copies of the Original File for Distribution..
Now the problem I face is that these files are getting created in the format shown in the last two files..

Now everytime I have to open these files using the Open With Dialog Box though these are normal files with no VBA code or even any kind of Macros in it..
So how do I repair this error ?
Please find the code below which I am using to create these files from my Sheets...
Code:
Public Sub MoveData()
Dim aScriptObject As Object, c, bScriptObject As Object
Dim ws As Worksheet, nBook As Workbook
Dim Nm As Name
Dim NewWkBkName As String
Dim FolderName As String
Dim WkBkPath As String
Dim NewWkBkFolder As String
Dim ShtCount
WkBkPath = Sheets("Insurance").Range("AC2").Value
NewWkBkFolder = Sheets("Insurance").Range("AC4").Value
NewWkBkName = Sheets("Insurance").Range("AC5").Value
Set aScriptObject = CreateObject("Scripting.FileSystemObject")
If Not aScriptObject.FolderExists(WkBkPath & NewWkBkFolder) Then
Set c = aScriptObject.CreateFolder(WkBkPath & NewWkBkFolder)
End If
Set bScriptObject = CreateObject("Scripting.FileSystemObject")
If bScriptObject.FileExists(WkBkPath & NewWkBkFolder & "\" & NewWkBkName & ".xlsm") Then
MsgBox "The File Name exists"
Exit Sub
End If
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "A* Book" Or ws.Name Like "B* Look" Then
ShtCount = ShtCount + 1
If ShtCount = 1 Then
Set nBook = Workbooks.Add
nBook.SaveAs WkBkPath & NewWkBkFolder & "\" & NewWkBkName, FileFormat:=xlOpenXMLWorkbookMacroEnabled 'xlNormal
End If
With ThisWorkbook
.Sheets(ws.Name).Copy Before:=Workbooks(NewWkBkName).Sheets(1)
Call DeleteCode
End With
End If
Next
For Each ws In Worksheets
If ws.Name Like "Sheet*" Then ws.Delete
Application.DisplayAlerts = False
Next ws
For Each Nm In Workbooks(NewWkBkName).Names
Nm.Delete
Next Nm
Application.DisplayAlerts = False
Workbooks(NewWkBkName).Close True
'Application.DisplayAlerts = True
End Sub
Can someone please guide me on the same this code which I am using is not my own but I am working around it..
Thanks in advance
Warm Regards
all4excel