Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing characters in excel with VBA 1

Status
Not open for further replies.

GlenLynam

MIS
Jul 26, 2002
121
Hi i have the following code...

Set objXL = Excel.Application 'New Excel.Application

objXL.Workbooks.Open ("\\server\shared$\Kitting Department\GSM despatch\GSM Shipments\" & strfilexls)
objXL.Visible = True
objXL.DisplayAlerts = False
objXL.Cells.Select
objXL.Range("G1").Activate
objXL.Replace What:=",", Replacement:=";", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
objXL.ActiveWorkbook.SaveAs FileName:="\\server\shared$\Kitting Department\GSM despatch\GSM Shipments\" & strfilecsv & ".csv", FileFormat:=xlCSV, CreateBackup:=False
objXL.Quit
Set objXL = Nothing


It works fine until you get to the line 'objXL.Replace What:=",", Replacement:=";",' at this point it errors out. t used to work in office xp but i need to get to work on a office 2k machine, an upgrade is out of the question.

I get application-defined or object-defined error. Any help that can be offered will be greatly appreciated.

Thanks

Glen
 


Hi,

Incorrect use of application object
Code:
            objXL.Visible = True
            objXL.DisplayAlerts = False
            [b]objXL.Range("G1").Replace What:=",", Replacement:=";", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False[/b]
            objXL.ActiveWorkbook.SaveAs FileName:="\\server\shared$\Kitting Department\GSM despatch\GSM Shipments\" & strfilecsv & ".csv", FileFormat:=xlCSV, CreateBackup:=False
            objXL.Quit
        Set objXL = Nothing
[/cpde]


Skip,
[sub]
[glasses] [b][red]A palindrome gone wrong?[/red][/b]
A man, a plan, a ROOT canal...
[b]PULLEMALL![/b][tongue][/sub]
 
Hi there,

Thanks for the reply but i get the same error as b4.

Regards

Glen
 


Some property of FIND is killing you. Try...
Code:
objXL.Range("G1").Replace What:=",", Replacement:=";"

Skip,
[sub]
[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top