[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 992
  • Last Modified:

[Excel + VB] Excel creates a file without extension...

Hello, everybody

I have a strange problem, which I didn't find any solution..
I'm currently using COM to export data to Excel from Visual basic 6.0.

This works fine, but "in some cases" (not always) I find another file in the same directory I'm using with the same name but without extension (xls). For instance, if I export to "test.xls", I find a file "test" in the same directory.

This file "test" is a 18k file, that opens the original file (test.xls), if double-clicked.
The file test.xls is created regularly, without any problem...

Any idea on this? Why this file is created? Can I safely delete it?

Any help is greatly appreciated
Thanks in advance,
Marco
0
Hit_MN
Asked:
Hit_MN
  • 6
  • 3
  • 2
  • +3
2 Solutions
 
DhaestCommented:
Can you post a piece of code (example where you save the excel-file)
0
 
harfangCommented:
It looks like a shortcut. If so, you can naturally delete it without problem, but I wonder how this gets created. What is the relevant portion of your code?
(°v°)
0
 
usarianCommented:
First, if the icon of the file without the extension show up as an Excel file?
Second, so your saying there are two files being created by the vb6 program, one with an extension, one without?

Sounds like the vb6 ap needs some tweaking.

Right click on the test file that has no extension, click OPEN WITH (or OPEN if the other isn't in the list) and open the file with notepad (make sure the ALWAYS OPEN WITH THIS bla bla bla box is not checked)

What's inside that file.. your excel data, say separated by commas or tabs, or a bunch of squares, then your data, or just gobbly gook?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Hit_MNAuthor Commented:
Dhaest: my code is something like this:

' Open the workbook:
Set m_objWorkbook = m_objExcel.Workbooks.Open(FileName)
...
' Save the data by row:
.Range(.Cells(firstRow, firstCol), .Cells(lastRow, lastCol)).Value = MyArrayOfValues

' Save and close the workbook
m_objWorkbook.SaveAs FileName
m_objWorkbook.Close

After the creation of the file, I can delete the test (without extension) without any problem from Explorer, but I didn't tried to delete it by code....

Thanks
Marco
0
 
Patrick MatthewsCommented:
Hello Marco,

Are you properly destroying those Excel objects?

Regards,

Patrick
0
 
Hit_MNAuthor Commented:
Usarian: the file has no icon...
Yes: there are two files being created by the vb6 program (Excel, actually!), one with an extension, one without?

The file seems to contain only the template data of the Excel file, without my data inside. In fact, I'm using an Excel file as the "template" where I'm writing the data inside... This test (without extension) file contains the template header, between some binary data sets.

matthewspatrick:I think I do... :D
I've got the following code in the _Terminate event of the class:

Private Sub Class_Terminate()
     m_objExcel.Application.Quit
   
    Set m_objWorkbook = Nothing
    Set m_objExcel = Nothing

End Sub


Thanks.
Marco
0
 
harfangCommented:
Does your variable FileName contain the extension? You are basically opening a file, writing data to it and closing it. Why use SaveAs? Don't you mean just .Save?
(°v°)
0
 
Hit_MNAuthor Commented:
harfang:yes, fileName contains the extension...

I'm using SaveAs because I'm currently using a class of mine that wraps Excel functions: this provides SaveAs interface only (for more generality in this).
Should this be a problem?

0
 
harfangCommented:
I suppose not, since the variable contains the extension... If you can reproduce this reliably, why don't you try to step through the code while watching an explorer window to see exactly when the file appears?
(°v°)
0
 
Jeroen RosinkCommented:
If im correct and you are able to delete the file without extensions and still you are able to open the original file then it seems to me that the temporary file which is created is not removed. In certain circumstances when the file is stored on the network this temporary file keeps existing while the original file is closed.
Sometimes it helps to close the application itself. Though true delay or inrobust network these files might keep existing while a system is polling for network connection.

regards,
Jeroen
0
 
Hit_MNAuthor Commented:
Here I am, again :D

I found out that the problem (on my PC) was due to the fact that ... I tried to save the file without extension!
That is: for a bug in my code (in the procedure that selects the file name, using the common dialog), I saved the file as C:\MyDirectory\test. It seems that Excel created this file _plus_ the correct .xls file "C:\MyDirectory\test", for some reason that I didn't investigated.

Now, the problem is on my customer's PC: my customer is saying me that this "without extension" file is always created. The difference is that before the bugfix (above) the file "without extension" was about 18k, now it is the same size of the file with the .xls extension.

The only difference is that my customer has Excel 2000, and I have 2003...
Any idea??

Thanks again for all the replies ...and for the next ones. :D
Marco
0
 
Hit_MNAuthor Commented:
By the way: Jeroen, I'm saving to my own PC, no network...
Thanks
0
 
Jeroen RosinkCommented:
If you move the file to another location and rename it with an .xls extension, are you able to open it as excel file? Then it still seems to me that it a temporary file.
Still it depends on which operating system and excel version you are using. Excel 2000 is using if im correct the exact file name as temporary file. Excel above renames it with 8 random chars.

Another option could be as you are mentioned to save the data by row, that there are rows which contains the same data and result into the same name, if you have turned displaying messages off, then the save action is made, still not finsished by adding the extension on the end.

regards,
Jeroen
0
 
Hit_MNAuthor Commented:
Thanks to both! :D
The problem was due to:

1. a bug which was missing the extension in the saved file name: it seems that Excel created the .xls file, but left the file without extension there.

2. I was calling m_objExcel.ScreenUpdating = False, but in some cases I was missing the related m_objExcel.ScreenUpdating = True at the end.

Thanks again,
Marco
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now