PDA

View Full Version : Application-defined or object-defined error



sowmya.mr
01-04-2013, 04:44 AM
Hi All,

I am exporting a form to excel and I want two columns to be replaced with Yes/No instead of True/False.

I have written the following code to export to excel and replace true/false with yes/no. But for the first time the code doesn't work.

Can anyone help me regarding this?

DoCmd.OutputTo acOutputForm, "Form1", acFormatXLSX, "", True

Columns("L:M").Select
Selection.Replace What:="True", Replacement:="Yes", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="False", Replacement:="No", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Kenneth Hobs
01-04-2013, 06:41 AM
Welcome to the forum! Please use VBA code tags when pasting code.

I gather this is VBA for Access and not Excel. As such, you need to prefix the Excel commands with the Excel application object and workbook object.

If it is Excel VBA code then you need to prefix the DoCmd with the access object and database.

Bob Phillips
01-04-2013, 10:29 AM
As such, you need to prefix the Excel commands with the Excel application object and workbook object.

And worksheet ...