EDN Admin
Well-known member
Greetings fellow coders...My gratitude for helping me learn.
I have a small app that writes data to an Excel file. That works fine, but instead of opening a SaveFile dialog to save it , I need to write to the new file (process my code) then have the file open. I have Googled to my hearts content and everything I
am finding is either what I have (open a Save File dialog) or hardcoding a save name/location....
Here is my save file code. What do I need to change in order for the file to simply open instead of the SaveFile dialog?:
<pre class="prettyprint Excel formatting above here...works, and I can save the file fine...below
Save As Excel File..
Dim SaveExTkAs As New SaveFileDialog
SaveExTkAs.Title = "Save Report"
SaveExTkAs.InitialDirectory = "C:"
SaveExTkAs.Filter = "Excel Workbook|*.xlsx"
SaveExTkAs.RestoreDirectory = True
ExTkApp1.DisplayAlerts = False
If SaveExTkAs.ShowDialog() = Windows.Forms.DialogResult.OK Then
Try
ExTkWksht1.SaveAs(SaveExTkAs.FileName)
ExTkApp1.DisplayAlerts = True
SaveExTkAs.Dispose()
ExTkWkbk1.Close()
ExTkApp1.Quit()
releaseObject(ExTkApp1)
releaseObject(ExTkWkbk1)
releaseObject(ExTkWksht1)
Catch ex As Exception
MsgBox("File Already Open" & vbCrLf & ex.Message, MsgBoxStyle.Critical)
ExTkWkbk1.Close()
ExTkApp1.Quit()
releaseObject(ExTkApp1)
releaseObject(ExTkWkbk1)
releaseObject(ExTkWksht1)
End Try
End If[/code]
<br/>
View the full article
I have a small app that writes data to an Excel file. That works fine, but instead of opening a SaveFile dialog to save it , I need to write to the new file (process my code) then have the file open. I have Googled to my hearts content and everything I
am finding is either what I have (open a Save File dialog) or hardcoding a save name/location....
Here is my save file code. What do I need to change in order for the file to simply open instead of the SaveFile dialog?:
<pre class="prettyprint Excel formatting above here...works, and I can save the file fine...below
Save As Excel File..
Dim SaveExTkAs As New SaveFileDialog
SaveExTkAs.Title = "Save Report"
SaveExTkAs.InitialDirectory = "C:"
SaveExTkAs.Filter = "Excel Workbook|*.xlsx"
SaveExTkAs.RestoreDirectory = True
ExTkApp1.DisplayAlerts = False
If SaveExTkAs.ShowDialog() = Windows.Forms.DialogResult.OK Then
Try
ExTkWksht1.SaveAs(SaveExTkAs.FileName)
ExTkApp1.DisplayAlerts = True
SaveExTkAs.Dispose()
ExTkWkbk1.Close()
ExTkApp1.Quit()
releaseObject(ExTkApp1)
releaseObject(ExTkWkbk1)
releaseObject(ExTkWksht1)
Catch ex As Exception
MsgBox("File Already Open" & vbCrLf & ex.Message, MsgBoxStyle.Critical)
ExTkWkbk1.Close()
ExTkApp1.Quit()
releaseObject(ExTkApp1)
releaseObject(ExTkWkbk1)
releaseObject(ExTkWksht1)
End Try
End If[/code]
<br/>
View the full article