PDA

View Full Version : constant error on excel start up



next
02-23-2008, 11:22 PM
I was playing around with VBA and used some code, don't remember the syntax, but basicaly it was supposed to create a word document, which i named "startWord.doc". VBA didn't generate any error, but it didn't create a document either. Now every time i start excel it displays an error message saying "startWord.doc: file format is not valid". How do i get rid of this message?

Brandtrock
02-23-2008, 11:34 PM
A few more details would help. For instance, where was this code placed? What exactly was the code?

The error you are getting is the one that is generated when you try to open a non Excel format with Excel. The code you were playing with must still be trying to open the document in Excel. Without more specifics, I'm afraid that is about as much help as I can be.

Regards,

next
02-24-2008, 12:07 AM
Sub UseWord()
Dim word As Object, doc As Object
Set word = CreateObject("Word.Application")
' Show Word (otherwise it's invisible).
word.Visible = True
' Create document.
Set doc = word.Documents.Add
' Insert some text
doc.Range.InsertAfter "Some text to insert."
' Save the file
doc.SaveAs ThisWorkbook.Path & "\StartWord.doc"
End Sub

That's the code. I placed it in a module, when this error message started buggin me i deleted the module, but it didn't solve anything.

tstav
02-24-2008, 12:30 AM
Hi next,
I am afraid there is something more than just the code you posted that you are missing... Your code worked fine with me.
You say

every time i start excel you get the error message.
EVERY TIME YOU START EXCEL?? Are you sure you have not done anything to your C:\Program Files\Microsoft Office 200X\OfficeXX\XLSTART folder? That is where Excel always looks when starting up....

next
02-24-2008, 12:28 PM
i'm not 100% sure, but i might have had this in the same module:

Sub GetWord( )
Dim word As Object, doc As Object
' Get a running instance of Word.
Set word = GetObject(, "Word.Application")
' Open a document.
Set doc = word.documents.Open(ThisWorkbook.Path & "\StartWord.doc")
word.Visible = True
End Sub


No, XLStart is empty.
My OS is Vista btw and i use office 2003.

next
02-24-2008, 12:35 PM
OMG, i just solved this issue in a very weird way.
There were no word documents in the same folder with the workbook, but this did the trick.

Sub testKill()
Dim xfile As String
xfile = ThisWorkbook.Path & "\startWord.doc"
Kill xfile
End Sub

Thanks anyway.

tstav
02-24-2008, 12:49 PM
I'm glad the frustration is over, next.
By the way...
What does OMG stand for, and also LOL that I've seen used by someone else?

Brandtrock
02-24-2008, 12:52 PM
OMG is Oh my God
LOL is Laugh out loud

tstav
02-24-2008, 01:00 PM
OMG, I would never have guessed FCOL!!! (For Crying Out Loud)
Just kidding. Thanks Brandtrock !

next
02-24-2008, 01:07 PM
I'm glad the frustration is over, next.
you said it, seeing that message 20 times a day was getting on my nervs :laugh2: .

You might also sometimes see:
ROFL - rolling on the floor & LMAO - laughing my ass off
Those and OMG with LOL are used the most on the web.