Amendment to macro to activate a named file, that's minimised on the taskbar.

yorkshirelad

Board Regular
Joined
Aug 18, 2003
Messages
100
I have a large macro for which the first task is to activate an open csv file then copy and paste data into a master file before formatting and processing the data.

It works brilliantly on my office system and others pcs but when I email it to a colleague in another office ( the one who needs to use it) it doesn't get past the first stage as it doesn't find the file cliente.csv that we know is already open.

Having looked at a screenshot of her explorer, it looks as though the csv files on her system, are in a slightly different format to standard, which is why the macro does not find the file. On mine its a plain csv filr, on her's its a Microsoft Office Excel file of sort - I can't find out the actual extension as she's had to leave the office for the day and I need to get this sorted for first thing tomorrow.

As this could be a problem on other systems too, is there away of activating the Excel compatible workbook named 'cliente' regardless of the file format?

This is the start of the macro which I've saved seperately. Any help would be really appreciated, this has taken hours of work, including creating video tutorials - it would be really frustrating if it failed because it couldn't find the file that we know is open.

Sub SCD_importClienteData()

Application.ScreenUpdating = False

On Error Resume Next
Windows("cliente.csv").Activate
'Set src = Workbooks(file).Worksheets(1)
If Err.Number = 9 Then
MsgBox "You need to open the cliente.csv file you'd like to import"
Err.Clear
Exit Sub
ElseIf Err.Number <> 0 Then
MsgBox Err.Number & ":" & Err.Description
Err.Clear
Exit Sub
Else
' do nothing
End If
On Error GoTo 0

Application.CalculateFullRebuild
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.WindowState = xlMinimized
Sheets("ClienteSolicitar").Select
Application.CalculateFullRebuild
Dim FirstBlankCell As Range
Set FirstBlankCell = Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
FirstBlankCell.Activate
ActiveSheet.Paste
Range("A3").Select
ActiveWindow.WindowState = xlMaximized

End Sub

Many thanks again for any assistance.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
This is a strange one - I've found the file format that doesn't work with the macro.

It should be the same - Microsoft Office Comma Seperated Values file, but for some reason it doesn't view it as the file that its looking for. The macro works on my system and on others where it has saved as the standard csv but not on hers, it doesn't see the file even though its open

Has anyone come across this before and is there any way around it? Is there a way of just looking for a file called 'cliente'.

Does Microsoft view 'Microsoft Office Comma Seperated Values file' as a workbook? Which is what the macro is looking for - my understanding is that CSV files are only one sheet, so is that still a workbook?

Sorry if I'm clutching at straws here but I need to resolve this somehow.

Many thanks for any assistance.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

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