Foffaf Foffaf
asked on
VB code to Create Excel file from Outlook 2007 part 3
Why is this code only creating VBA folder but nothing inside? How do you fix it?
Note:
This question is related to these question
VB code to Create Excel file from Outlook 2007 part 2 - https://www.experts-exchange.com/questions/24163884/VB-code-to-Create-Excel-file-from-Outlook-2007-part-2.html?anchorAnswerId=23699562#a23699562
VB code to Create Excel file from Outlook 2007 part 1 - https://www.experts-exchange.com/questions/24139919/VB-code-to-Create-Excel-file-from-Outlook-2007.html
Note:
This question is related to these question
VB code to Create Excel file from Outlook 2007 part 2 - https://www.experts-exchange.com/questions/24163884/VB-code-to-Create-Excel-file-from-Outlook-2007-part-2.html?anchorAnswerId=23699562#a23699562
VB code to Create Excel file from Outlook 2007 part 1 - https://www.experts-exchange.com/questions/24139919/VB-code-to-Create-Excel-file-from-Outlook-2007.html
Sub CreateExcel2()
Dim objExcel As Object
Dim sExcelFilePath As String
Dim objFSO As Object
Dim objFolder As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
sExcelFilePath = "e:\temp\VBA\test.xlsx"
On Error Resume Next
Set objFolder = objFSO.GetFolder(objFSO.GetParentFolderName(sExcelFilePath))
On Error Resume Next
If TypeName(objFolder) Then
Set objFolder = objFSO.CreateFolder(objFSO.GetParentFolderName(sExcelFilePath))
End If
objExcel.Workbooks.Add
objExcel.ActiveWorkbook.SaveAs sExcelFilePath
Set objFSO = Nothing
Set objFolder = Nothing
End Sub
0ffa,
Any update?
chris_bottomley
Any update?
chris_bottomley
ASKER
chris_bottomley,
I tried the code, when I ran it seems like the program stuck for a minute. I check on the path, its correctly created the file for me, but I can't open the file unless I do 'end task' the excel through Task Manager. So it seems the code doesn't exit or close the excel properly.
Sorry for replying this late, please bear with me coz I only can try this programming stuff on my spare time. Thx.
I tried the code, when I ran it seems like the program stuck for a minute. I check on the path, its correctly created the file for me, but I can't open the file unless I do 'end task' the excel through Task Manager. So it seems the code doesn't exit or close the excel properly.
Sorry for replying this late, please bear with me coz I only can try this programming stuff on my spare time. Thx.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The code is working Chris :)
ASKER
chris_bottomley,
I post a new related question in:
https://www.experts-exchange.com/questions/24279744/VB-code-to-Create-Excel-file-from-Outlook-2007-part-3-1.html
I post a new related question in:
https://www.experts-exchange.com/questions/24279744/VB-code-to-Create-Excel-file-from-Outlook-2007-part-3-1.html
When you create the excel workbook you use objexcel which is undefined therefore there is no workbook to save.
Try as attached
Chris
Open in new window