Run-time error '1004': problem

Joined
Dec 3, 2008
Messages
33
Hi all,

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.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
dont know if this helps but it seems if you save from an old format to a new it will convert

SaveAsOldFileFormat Method

In a host application such as Microsoft PowerPoint, saves a chart in the specified older file format.
expression.SaveAsOldFileFormat(MajorVersion, MinorVersion)
<TR>expression Required. An expression that returns an Application object.</TR> <TR>MajorVersion Optional Variant. Specifies the major version number of the file format you want to use.</TR> <TR>MinorVersion Optional Variant. Specifies the minor version number of the file format you want to use.</TR>
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,522
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top