RRLR
August 10th, 2008, 02:37 PM
Hello I have been Writing scripts in Visual Basic to Export .txt files to .xls files.
The Script I Use works it opens the file , opens the Model, and export it to the location I have chosen.
Now My Problem is that When I Export the file Manually the Format is Different, the excel file has a Greyed out Headers and the Columns are sized accordingly to the Data and Headers.
Is there any bit of Code that I can add to my Script to allow for the same Look as when I Manually Export it.
The Code I'm Using is based off the Programmer Guide for Monarch. Just with out the Filters.
If anyone can help that Would be great.
Private Sub Form_Load()
Dim MonarchObj As Object
Dim openfile, openmod, t As Boolean
'If Monarch is currently active GetObject will use Monarch. If it is not use the CreateObject() to
'open another copy of Monarch.
Set MonarchObj = GetObject("", "Monarch32")
If MonarchObj Is Nothing Then
Set MonarchObj = CreateObject("Monarch32")
End If
t = MonarchObj.SetLogFile("C:\MonTemp\MPrg_G5.log", False)
openfile = MonarchObj.SetReportFile("\\BLAH\Blah\Blah\Blah.txt", False)
If openfile = True Then
openmod = MonarchObj.SetModelFile("\\BLAH\Blah\Blah\Blah.xmod")
If openmod = True Then
'Set filter for each frame and export to Excel
MonarchObj.ExportTable ("\\BLAH\Blah\Blah\Blah.xls")
End If
End If
MonarchObj.CloseAllDocuments
t = MonarchObj.SetLogFile("C:\MonTemp\MPrg_G5.log", False)
openfile = MonarchObj.SetReportFile("\\BLAH\Blah\Blah\Blah.txt", False)
If openfile = True Then
openmod = MonarchObj.SetModelFile("\\BLAH\Blah\Blah\Blah.xmod")
If openmod = True Then
'Set filter for each frame and export to Excel
MonarchObj.ExportTable ("\\BLAH\Blah\Blah\Blah.xls")
End If
End If
MonarchObj.CloseAllDocuments
MonarchObj.Exit
End Sub
The Script I Use works it opens the file , opens the Model, and export it to the location I have chosen.
Now My Problem is that When I Export the file Manually the Format is Different, the excel file has a Greyed out Headers and the Columns are sized accordingly to the Data and Headers.
Is there any bit of Code that I can add to my Script to allow for the same Look as when I Manually Export it.
The Code I'm Using is based off the Programmer Guide for Monarch. Just with out the Filters.
If anyone can help that Would be great.
Private Sub Form_Load()
Dim MonarchObj As Object
Dim openfile, openmod, t As Boolean
'If Monarch is currently active GetObject will use Monarch. If it is not use the CreateObject() to
'open another copy of Monarch.
Set MonarchObj = GetObject("", "Monarch32")
If MonarchObj Is Nothing Then
Set MonarchObj = CreateObject("Monarch32")
End If
t = MonarchObj.SetLogFile("C:\MonTemp\MPrg_G5.log", False)
openfile = MonarchObj.SetReportFile("\\BLAH\Blah\Blah\Blah.txt", False)
If openfile = True Then
openmod = MonarchObj.SetModelFile("\\BLAH\Blah\Blah\Blah.xmod")
If openmod = True Then
'Set filter for each frame and export to Excel
MonarchObj.ExportTable ("\\BLAH\Blah\Blah\Blah.xls")
End If
End If
MonarchObj.CloseAllDocuments
t = MonarchObj.SetLogFile("C:\MonTemp\MPrg_G5.log", False)
openfile = MonarchObj.SetReportFile("\\BLAH\Blah\Blah\Blah.txt", False)
If openfile = True Then
openmod = MonarchObj.SetModelFile("\\BLAH\Blah\Blah\Blah.xmod")
If openmod = True Then
'Set filter for each frame and export to Excel
MonarchObj.ExportTable ("\\BLAH\Blah\Blah\Blah.xls")
End If
End If
MonarchObj.CloseAllDocuments
MonarchObj.Exit
End Sub