K
Keith_Miland
I get a "run-time error 1004 error" Method 'GetSaveAsFile' of object'_Application'failed.
This macro was created by what version I don't know. I've opened it and saved it to Excel 2004 for Mac.
Basically this sub should take data from an Excel spreadsheet and put it in a csv format with a file name of month, day.mt1.
I am no programmer. I was able to figure out on other macros I had that the \ needed to be replaced with : to make it work sort of. Even with those macros "working", part of it is to save a file. The macro does but in addition to saving where the macro tells it, it also wants to save in a second spot on the computer. If I pay attention and change the location back to the correct location, I get asked if I want to overwrites the file it just saved in the correct location. It's a bother, but I can live with that for now.
It's more important that I get this to work because this .mt1 extension works with a program I use. Importing the mt1 is 10 times quicker than entering the data by hand.
Here is the sub written by someone else:
Sub exportmt1(division, MT1FileName)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' this sub handles writing the mt1 export
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MT1FileName = Left(division, 4) & Format(Month(Now), "00") & Format(Day(Now), "00") & ".MT1"
'-------
MT1FileName = Application.GetSaveAsFilename(initialFileName:=MT1FileName, _
fileFilter:="Metrix Meter Files (*.MT1),*.MT1", filterIndex:=1, Title:="FastData Save As")
If MT1FileName = False Then Exit Sub
Open MT1FileName For Output As #1
Application.DisplayAlerts = True
RdRow = 7
While Cells(RdRow, 1).Text ""
Print #1, "MT1";
For RdCol = 1 To 43
If RdCol = 6 Then
Print #1, ","; Year(Cells(RdRow, RdCol)); ","; Month(Cells(RdRow, RdCol)); ","; Day(Cells(RdRow, RdCol));
Else
Print #1, ","; Cells(RdRow, RdCol);
End If
Next RdCol
Print #1,
RdRow = RdRow + 1
Wend
Close
End Sub
Any help would be greatly appreciated.
This macro was created by what version I don't know. I've opened it and saved it to Excel 2004 for Mac.
Basically this sub should take data from an Excel spreadsheet and put it in a csv format with a file name of month, day.mt1.
I am no programmer. I was able to figure out on other macros I had that the \ needed to be replaced with : to make it work sort of. Even with those macros "working", part of it is to save a file. The macro does but in addition to saving where the macro tells it, it also wants to save in a second spot on the computer. If I pay attention and change the location back to the correct location, I get asked if I want to overwrites the file it just saved in the correct location. It's a bother, but I can live with that for now.
It's more important that I get this to work because this .mt1 extension works with a program I use. Importing the mt1 is 10 times quicker than entering the data by hand.
Here is the sub written by someone else:
Sub exportmt1(division, MT1FileName)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' this sub handles writing the mt1 export
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MT1FileName = Left(division, 4) & Format(Month(Now), "00") & Format(Day(Now), "00") & ".MT1"
'-------
MT1FileName = Application.GetSaveAsFilename(initialFileName:=MT1FileName, _
fileFilter:="Metrix Meter Files (*.MT1),*.MT1", filterIndex:=1, Title:="FastData Save As")
If MT1FileName = False Then Exit Sub
Open MT1FileName For Output As #1
Application.DisplayAlerts = True
RdRow = 7
While Cells(RdRow, 1).Text ""
Print #1, "MT1";
For RdCol = 1 To 43
If RdCol = 6 Then
Print #1, ","; Year(Cells(RdRow, RdCol)); ","; Month(Cells(RdRow, RdCol)); ","; Day(Cells(RdRow, RdCol));
Else
Print #1, ","; Cells(RdRow, RdCol);
End If
Next RdCol
Print #1,
RdRow = RdRow + 1
Wend
Close
End Sub
Any help would be greatly appreciated.