IanMackayinAmsterdam
New Member
- Joined
- Dec 3, 2008
- Messages
- 33
Hi all,
I have a small problem in a script I'm trying to run.
I apologise in advance for my poor script writing abilities, I'm no expert unfortunately.
What I want to do is prompt the user to export a file (as a text file) to a cetain location. All worked fine, but the text file was not formatted properly.
I assumed I had to tell excel which parameters the text file needed to be so I added FileFormat:=xlText to the code but now it gives me the run-time error mentioned above.
Can anyone tell me what I'm doing wrong here?
Much appreciated as always.
Ian.
I have a small problem in a script I'm trying to run.
Code:
Sub SaveBox_txt()
Dim Answer As String
Dim MyNote As String
Dim mydate As String
Dim store As String
Dim store2 As String
Dim temp As String
Dim k As Integer
mydate = Format(Now(), "yymmdd")
store = mydate
k = Len(store)
For x = 1 To k
temp = Mid(store, x, 1)
Debug.Print temp
If temp <> "/" Then store2 = store2 + temp
Debug.Print temp, store2
temp = ""
Next
MyNote = "Save files?"
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Save")
If Answer = vbNo Then
GoTo MacroEnd
Else
Workbooks.Open Filename:="H:\Operations\Central Planning - Control\Mens_Womens_Bodywear\PRICING\WOMENS\HO11 PS12\Upload file creator HO11.xls"
Workbooks("Price upload template HO11 WSW").Activate
Sheets("Price Upload Template LLO").Select
Range("A1:I148").Copy
Workbooks("Upload file creator HO11").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("A:I").EntireColumn.EntireColumn.AutoFit
Rows("149:149").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete
Range("A1").Select
ActiveSheet.SaveAs Filename:=Save1.InboundTextBox1.Text & "\" & Save1.TextBox4.Text & " " & Sheet8.Range("C2").Text & " " & store2 & ".txt", FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Save
Workbooks(Save1.TextBox4.Text & " " & Sheet8.Range("C2").Text & " " & store2 & ".txt").Close
End If
MacroEnd:
I apologise in advance for my poor script writing abilities, I'm no expert unfortunately.
What I want to do is prompt the user to export a file (as a text file) to a cetain location. All worked fine, but the text file was not formatted properly.
I assumed I had to tell excel which parameters the text file needed to be so I added FileFormat:=xlText to the code but now it gives me the run-time error mentioned above.
Can anyone tell me what I'm doing wrong here?
Much appreciated as always.
Ian.