I just can't figure what I'm doing wrong with this code. Can anyone assist
The spreadsheet I want to place information into has about 15 Sheets
Foxdata has around 500 entries
With loExcel
.Workbooks.Open(lcFile)
Scan
Select foxdata
If !balance=0
Mdata =Alltrim(foxdata.sheet2) && EG "J16"
*Msheet="SHEET"+ALLTRIM(sheet1) && EG "Expenses"
Msheet="SHEET"+ALLTRIM(STR(sheetnum)) && If I use the sheet number
instead
.Sheet("&msheet").Select
This is where it comes up with error "invalid index"
.Range("&Mdata").Select
I get an occasional error here
.Selection=foxdata.balance
Endif
Endscan
.ActiveWindow.Close(xlSaveChanges)
.Quit()
Endwith
--
Kind regards,
Sytze de Boer
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAG1nNy8wkWzHLg+hm-tw+o0qzFqVyGbN8j_p1r8amtSoXRUi_Q@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
why have you got "" as well as & ?
Al
-----Original Message-----
From: Sytze de Boer
Sent: Thursday, May 5, 2016 2:09 AM
To: profoxtech@leafe.com
Subject: VFP to XLSX file
I just can't figure what I'm doing wrong with this code. Can anyone assist
The spreadsheet I want to place information into has about 15 Sheets
Foxdata has around 500 entries
With loExcel
.Workbooks.Open(lcFile)
Scan
Select foxdata
If !balance=0
Mdata =Alltrim(foxdata.sheet2) && EG "J16"
*Msheet="SHEET"+ALLTRIM(sheet1) && EG "Expenses"
Msheet="SHEET"+ALLTRIM(STR(sheetnum)) && If I use the sheet number
instead
.Sheet("&msheet").Select
This is where it comes up with error "invalid index"
.Range("&Mdata").Select
I get an occasional error here
.Selection=foxdata.balance
Endif
Endscan
.ActiveWindow.Close(xlSaveChanges)
.Quit()
Endwith
--
Kind regards,
Sytze de Boer
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/6734B96B08084A9B8048F0B4682908CD@gslredacer
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Because msheet could be msheet1, or msheet2 etc
If I take the "" away, it comes up with Variable sheet6 is not found
On Thu, May 5, 2016 at 7:02 PM, Allen <profox@gatwicksoftware.com> wrote:
> why have you got "" as well as & ?
> Al
>
> -----Original Message----- From: Sytze de Boer
> Sent: Thursday, May 5, 2016 2:09 AM
> To: profoxtech@leafe.com
> Subject: VFP to XLSX file
>
>
> I just can't figure what I'm doing wrong with this code. Can anyone assist
> The spreadsheet I want to place information into has about 15 Sheets
> Foxdata has around 500 entries
>
>
> With loExcel
> .Workbooks.Open(lcFile)
> Scan
> Select foxdata
> If !balance=0
> Mdata =Alltrim(foxdata.sheet2) && EG "J16"
> *Msheet="SHEET"+ALLTRIM(sheet1) && EG "Expenses"
> Msheet="SHEET"+ALLTRIM(STR(sheetnum)) && If I use the sheet number
> instead
> .Sheet("&msheet").Select
> This is where it comes up with error "invalid index"
>
> .Range("&Mdata").Select
> I get an occasional error here
>
> .Selection=foxdata.balance
> Endif
>
> Endscan
> .ActiveWindow.Close(xlSaveChanges)
> .Quit()
> Endwith
>
>
>
> --
> Kind regards,
> Sytze de Boer
>
>
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
> text/plain (text body -- kept)
> text/html
> ---
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAG1nNy8LF4VVCO1qi72zuycxBHCNri1H+3COr+wgHPZY9_airQ@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
I think it will pass &msheet as a string instead of whatever msheet is
Al
-----Original Message-----
Because msheet could be msheet1, or msheet2 etc
If I take the "" away, it comes up with Variable sheet6 is not found
On Thu, May 5, 2016 at 7:02 PM, Allen <profox@gatwicksoftware.com> wrote:
> why have you got "" as well as & ?
> Al
>
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/A31D46C0AC2B46A0ADE784A669A121F9@gslredacer
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On 05/05/2016 08:15, Allen wrote:
> I think it will pass &msheet as a string instead of whatever msheet is
> Al
>
Yes, you don't need to use & when doing automation.
E.g.
cCell = "B" + ALLTRIM(STR(nRow)) && get some data from a table e.g.
B1 B2 etc
objexcel.Range(cCell).Select
cRow = ALLTRIM(STR(nRow)) + ':' + ALLTRIM(STR(nRow)) && could be
45:45 72:74 etc
OBJexcel.Rows(cRow).RowHeight = 93
Peter
This communication is intended for the person or organisation to whom it is addressed. The contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful. If you have received this message in error, please notify us immediately by telephone or email.
www.whisperingsmith.com
Whispering Smith Ltd Head Office:61 Great Ducie Street, Manchester M3 1RR.
Tel:0161 831 3700
Fax:0161 831 3715
London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/572B2329.4060006@whisperingsmith.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
If you want to pass as a variable then it should be without the quotes else
it passes as a string.
--
Cheers!!!
*Srikanth Bhandari*
Mobile: +91 99625 42134 / +91 99001 39393
Email: consultant@srikanthbhandari.ind.in / srikanth.bhandaari@gmail.com
Web: srikanthbhandari.ind.in
On Thu, May 5, 2016 at 4:10 PM, Peter Cushing <pcushing@whisperingsmith.com>
wrote:
> On 05/05/2016 08:15, Allen wrote:
>
>> I think it will pass &msheet as a string instead of whatever msheet is
>> Al
>>
>> Yes, you don't need to use & when doing automation.
>
> E.g.
>
>
> cCell = "B" + ALLTRIM(STR(nRow)) && get some data from a table e.g. B1
> B2 etc
> objexcel.Range(cCell).Select
>
> cRow = ALLTRIM(STR(nRow)) + ':' + ALLTRIM(STR(nRow)) && could be
> 45:45 72:74 etc
> OBJexcel.Rows(cRow).RowHeight = 93
>
> Peter
>
>
> This communication is intended for the person or organisation to whom it
> is addressed. The contents are confidential and may be protected in law.
> Unauthorised use, copying or disclosure of any of it may be unlawful. If
> you have received this message in error, please notify us immediately by
> telephone or email.
> www.whisperingsmith.com
>
> Whispering Smith Ltd Head Office:61 Great Ducie Street, Manchester M3 1RR.
> Tel:0161 831 3700 Fax:0161 831 3715
> London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
>
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAHyviJrHQBcnsspJ+iYD1LdtfiyMxH4EpDwoyLzfp8-=k52dAg@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Fellow foxers
I have resolved the issue I encountered.
The following works well
sele foxdata
go top
With loExcel
.Workbooks.Open(lcFile)
scan
Mdata =Alltrim(foxdata.sheet2) && EG "J16"
Msheet=ALLTRIM(sheet1) && EG "Expenses"
.Application.Worksheets("&msheet").Activate && Select sheet
.Range("&Mdata").Select
.Selection=foxdata.balance
ETC
In other words, the problem was not with "" or & and all red herrings
In the end I found the problem that the sheets in the spreadsheet were
protected
Once I re-created the spreadsheet and did not make the sheets Protected,
all problems went away.
On Thu, May 5, 2016 at 11:29 PM, Srikanth Bhandari <
consultant@srikanthbhandari.ind.in> wrote:
> If you want to pass as a variable then it should be without the quotes else
> it passes as a string.
>
> --
> Cheers!!!
>
> *Srikanth Bhandari*
> Mobile: +91 99625 42134 / +91 99001 39393
> Email: consultant@srikanthbhandari.ind.in / srikanth.bhandaari@gmail.com
> Web: srikanthbhandari.ind.in
>
> On Thu, May 5, 2016 at 4:10 PM, Peter Cushing <
> pcushing@whisperingsmith.com>
> wrote:
>
> > On 05/05/2016 08:15, Allen wrote:
> >
> >> I think it will pass &msheet as a string instead of whatever msheet is
> >> Al
> >>
> >> Yes, you don't need to use & when doing automation.
> >
> > E.g.
> >
> >
> > cCell = "B" + ALLTRIM(STR(nRow)) && get some data from a table e.g. B1
> > B2 etc
> > objexcel.Range(cCell).Select
> >
> > cRow = ALLTRIM(STR(nRow)) + ':' + ALLTRIM(STR(nRow)) && could be
> > 45:45 72:74 etc
> > OBJexcel.Rows(cRow).RowHeight = 93
> >
> > Peter
> >
> >
> > This communication is intended for the person or organisation to whom it
> > is addressed. The contents are confidential and may be protected in law.
> > Unauthorised use, copying or disclosure of any of it may be unlawful. If
> > you have received this message in error, please notify us immediately by
> > telephone or email.
> > www.whisperingsmith.com
> >
> > Whispering Smith Ltd Head Office:61 Great Ducie Street, Manchester M3
> 1RR.
> > Tel:0161 831 3700 Fax:0161 831 3715
> > London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
> >
> >
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAG1nNy_1THJKWS01TzEFK-xehNkVbDE0K5WkWA5xjj+6HzC5yA@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.