Dear All,
I'm using VFP 6.0 to modify Excel report. I modify cell merge, background color, no pattern, etc. If I save it manually, I will get what I see. If I make the application save the file. It will loose these setting. Can anyone help?
oExcel = createObject("Excel.Application" && i open existing file here
with oExcel
.Application.visible = .t. &&if you want to see what you are doing
.displayAlerts = false
.workbooks.open(myXLSFile)
.sheets("PRIT_TYIELD".select
.
.
.
With .ActiveSheet.PageSetup
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False && set black and white off
EndWith
.
.
.Range("A5:F10".Select
With .Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True && I lost this setting
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
EndWith
.
.
With .Selection.Interior
.ColorIndex = 34 && I lost this setting
.Pattern = xlSolid && I lost this setting
.PatternColorIndex = xlAutomatic && I lost this setting
EndWith
.
.
.ActiveWorkbook.Save
endwith
Sorry, I cannot duplicate your problem, by using your code (and fixing the missing constans values), and save, and reopened and the changes are still there. Is it possible that you are loading a read-only file and since you disabling the alerts, you are missing the message? Set the alerts back on and see what you get.
Mike Gagnon
If you want to get the best response to a question, please check out FAQ184-2483 first.
Is it OK to write in VFP 'false' or 'true' instead of F or T ?
And i use values instead of eg 'xlNone' (=-4142 - these values you can find in Object Browser In VBA)
Is it OK to write in VFP 'false' or 'true' instead of F or T ?
No. Those values are for VB; they won't work in VFP. The usual technique is to use #DEFINE to set FALSE equal to .F. and TRUE to .T.
On the other hand, that probably isn't the cause of KonLao's problem. If he didn't have the #DEFINEs, he would have got an error before he reached the .Save.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.