Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

hiding gridline in excel using ole

119 views
Skip to first unread message

Brijesh

unread,
Dec 18, 2009, 3:36:43 AM12/18/09
to
Hi Group,
I am exporting a datawindow report to a excel using the ole. I have
to
format the exported reported in excel as per the exact copy of the
datawindow report. I want to hide the gridlines in excel
below is the few lines for code.

li_rc = inv_ole.connecttoobject(as_input)


inv_ole.Application.Windows(1).Visible=TRUE
inv_ole.Application.Windows(1).Activate


inv_ole.Application.Workbooks(1).Worksheets(1).Range(ls_from
+":"+ls_to ).MergeCells = True
inv_ole.Application.Workbooks(1).Worksheets(1).cells(li_start,
1).value
= ls_data
inv_ole.Application.Workbooks(1).Worksheets(1).cells(li_start,
1).Font.Bold = True
inv_ole.Application.Workbooks(1).Worksheets(1).cells(li_start,
1).Font.size = 12


What i want is to switch off the gridlines in worksheet(1).
Can anybody suggest code for this.


Regards,
-Brijesh


Wheeley

unread,
Dec 20, 2009, 1:20:14 AM12/20/09
to
On Fri, 18 Dec 2009 00:36:43 -0800 (PST), Brijesh
<brijesh...@gmail.com> wrote:

I have seen alot of these types of questions lately. People asking for
answers which are relatively easy to figure out. Please do a little
research before asking your question. You may actaully find someting
useful in the process like printing and viewing the gridlines have
totally different methods involved. To get your answer, open the vba
editor in Excel and search the help for "Grid" and look at the
worksheet view object. That is what I did before I wrote this response
since I was curious also. Or you can start macro recording and simply
perform the action in Excel and then look at the recorded macro.
Personally, I prefer doing tne research since more than often the
macro show a method wjich is not neceassrily the best way to ;erform
the desired action.

Wheeley

Brijesh

unread,
Dec 21, 2009, 2:43:07 AM12/21/09
to
On Dec 20, 11:20 am, Wheeley <whee...@ix.netcom.com> wrote:
> On Fri, 18 Dec 2009 00:36:43 -0800 (PST), Brijesh
>
> >-Brijesh- Hide quoted text -
>
> - Show quoted text -


Thanks for your reply Wheeley. I did the research on this before
posting this. I am not very expert in these so sought group help on
this. What i have found in the help is the below code..

Workbooks("BOOK1.XLS").Worksheets("Sheet1").Activate
ActiveWindow.DisplayGridlines = Not(ActiveWindow.DisplayGridlines)

I have tried below code but didn't help me at all.

inv_ole.Application.Workbooks(1).Worksheets(1).DisplayGridlines= False

i may be using it wrong so need your help with this.

Thanks
-Brijesh

Wheeley

unread,
Dec 22, 2009, 2:15:33 AM12/22/09
to
On Sun, 20 Dec 2009 23:43:07 -0800 (PST), Brijesh
<brijesh...@gmail.com> wrote:

Your problem is you are not understanding how Excel works. And here is
where you need to read more. Windows and worksheets are two different
objects in Excel. I'll give you the code but you need to read further
about windows. Also, if you print the workbook you are creating, you
WILL get gridilines. Here's the code as it should be written. Lots of
changes which you need to research.

myoleobject lnv_workbook, lnv_worksheet

lnv_workbook = Create lnv_workbook
lnv_worksheet = Create lnv_workbook

li_rc = inv_ole.connecttoobject (as_input)

if li_rc = 0 then
lnv_workbook.SetAutomationPointer(inv_ole.Application.Workbooks(1))
lnv_workbook.Windows(1).DisplayGridlines = FALSE
lnv_worksheet.SetAutomationPointer (lnv_workbook.Worksheets(1))

lnv_worksheet.Range(ls_from+":"+ls_to ).MergeCells = True
lnv_worksheet.cells(li_start,1).value = ls_data
lnv_worksheet.cells(li_start,1).Font.Bold = True
lnv_worksheet.cells(li_start,1).Font.size = 12
end if

Destroy lnv_worksheet
Destroy lnv_workbook


hop this helps
Wheely

Brijesh

unread,
Dec 22, 2009, 5:57:21 AM12/22/09
to
On Dec 22, 12:15 pm, Wheeley <whee...@ix.netcom.com> wrote:
> On Sun, 20 Dec 2009 23:43:07 -0800 (PST), Brijesh
>
> >-Brijesh- Hide quoted text -
>
> - Show quoted text -

Thanks a lot Wheely for your help with this. It has worked now.
Regards,
-Brijesh

abian...@gmail.com

unread,
Jan 6, 2015, 4:07:35 PM1/6/15
to
On Tuesday, December 22, 2009 2:15:33 AM UTC-5, Wheeley wrote:
> On Sun, 20 Dec 2009 23:43:07 -0800 (PST), Brijesh
> <brijesh...@gmail.com> wrote:
>
> Your problem is you are not understanding how Excel works. And here is
> where you need to read more. Windows and worksheets are two different
> objects in Excel. I'll give you the code but you need to read further
> about windows. Also, if you print the workbook you are creating, you
> WILL get gridilines. Here's the code as it should be written. Lots of
> changes which you need to research.
>
>
> You're the man Wheely...saved me a bunch of research. :)
0 new messages