Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Header align

Hi guys,

I'm exporting to excel using this code

set XLApp = CreateObject("Excel.Application")

XLApp.DisplayAlerts = False

XLApp.Visible = true

set XLDOC = XLApp.Workbooks.Open ("C:\Blank template.xlsx")

ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true

XLDOC.Sheets(1).Range("a8").Select

XLDoc.Sheets(1).Paste()

Despite what i put in the chart or in the template the header center aligns and i want it to left align. I've tried all sorts of things but i'm stuck - can anyone suggest anything?

1 Solution

Accepted Solutions
Not applicable
Author

Hi Paul,

Try like that:

sub test

set XLApp = CreateObject("Excel.Application")

XLApp.DisplayAlerts = False

XLApp.Visible = true

set XLDOC = XLApp.Workbooks.Open ("C:\Blank template.xlsx")

ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true

XLDOC.Sheets(1).Range("a8").Select

XLDoc.Sheets(1).Paste()

'you can change range here

XLDOC.Sheets(1).Range("A8:C8").HorizontalAlignment = -4131

end sub

BR,

Kuba

View solution in original post

2 Replies
Not applicable
Author

Hi Paul,

Try like that:

sub test

set XLApp = CreateObject("Excel.Application")

XLApp.DisplayAlerts = False

XLApp.Visible = true

set XLDOC = XLApp.Workbooks.Open ("C:\Blank template.xlsx")

ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true

XLDOC.Sheets(1).Range("a8").Select

XLDoc.Sheets(1).Paste()

'you can change range here

XLDOC.Sheets(1).Range("A8:C8").HorizontalAlignment = -4131

end sub

BR,

Kuba

Anonymous
Not applicable
Author

Thats great thank you