View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
JON JON JON JON is offline
external usenet poster
 
Posts: 62
Default Saving file to *.prn format

Hello Dave

I got 25.6 GB of free space.
I do have Admin access to my PC.
I have tried to save it manually and it works fine. However, when I run
the recorded macro, it also shows the same error as the one I have written.

I am getting frustrated. I am suspecting that it has something to do with
the file I am saving but can't figure it out.

Jon-jon


"Dave Peterson" wrote in message
...
I don't have any real good guesses.

But I do have some bad ones!

Is there enough space on that drive?
Do you have write access to your harddrive?
If you do it manually, what happens?

If it worked manually, record macro and compare it with your code to see
if
there's a difference.

(I got nothin')

JON JON wrote:

Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it can
neither be opened nor marked read-only. The error message is "Run time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it
open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

--

Dave Peterson


--

Dave Peterson