View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
smokiibear smokiibear is offline
external usenet poster
 
Posts: 33
Default savecopyas issues

I am attempting to use savecopyas method in order to take a processed csv
file, to which I add additional sheets, including some output data and a
chart.

The problem occurs in that I've coded a form with the option of creating
a chart of the output. When I select the option to create a chart, the
processed csv file saves perfectly as an excel file (with the original
input data, output data, and a chart). However, when the option to chart
the data is not selected, the processed csv file only saves one of the
worksheets...and it's garbeled at that. Instead of the output being
displayed in four separate colums, all the data gets jammed into one
colum and separted by commas.

What's so bizarre is that the output routine occurs before that chart
routine and therefore independent of it.

Here is the code for the main body of the program. If someone would
desire to look at more, I'd be happy to forward an example of the input
data, an output file, even the rest of the code. And I'd be obliged to
receive any critique offered.

Thanks everyone for the great help you've been to my recent posts.

Smokii

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
Option Explicit
Option Base 1

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'These variables declared here because they cannot be passed as arguments
between form
'and modules
Public ppi As Double
Public DispTol As Double
Public MaxErr As Double

Public NoXSec As Integer

Public cancelflag As Boolean
Public OpenFileflag As Integer

Public filelist() As String



Sub Main()

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
Dim ncracks As Integer

Dim i As Long

Dim Time1 As Double
Dim Runtime As Double

Dim vsplit As Variant

Dim cracks() As Double
ReDim cracks(1 To 3, 1 To 1000) As Double
'cracks(1,j) x
'cracks(2,j) y
'cracks(3,j) w

Dim xlsfilelist() As String

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'show Inputsettings user form
fmInputSettings.Show

'End routine if user clicks cancel
If cancelflag Then
End
End If

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'Store InputSettings variables
ppi = fmInputSettings.tbppi.Value
DispTol = fmInputSettings.tbDispTol.Value
MaxErr = fmInputSettings.tbMaxErr.Value
NoXSec = fmInputSettings.tbNoXSec.Value


'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'Open File Options
Call Files(filelist, xlsfilelist)


'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'Start Timer
Time1 = Timer

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'Turns off screen updating for faster processing
Application.ScreenUpdating = False

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'Begin Processing

For i = 1 To UBound(filelist)
Workbooks.Open filename:=filelist(i)

ActiveSheet.Select


'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
Call DEL_Error(MaxErr)
Call NewOD
Call cracksolve(NoXSec, DispTol, cracks, ncracks)
Call Out(cracks, ncracks)
If fmInputSettings.cbGraph Then Call Graph(ncracks)

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
With ActiveWorkbook
.SaveCopyAs filename:=xlsfilelist(i)
.Close savechanges:=False
End With


'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'Clear Cracks Array
ReDim cracks(1 To 3, 1 To 1000) As Double

Next i


'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'End Timer
Runtime = Timer - Time1
MsgBox Runtime

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
'Turns on screen updating
Application.ScreenUpdating = True

End Sub