减少excel中的行继续

时间:2016-03-04 01:39:30

标签: excel vba excel-vba

我正在尝试使用VBA创建excel创建XML文件(这是我的第一次),所以我设法创建了一个代码,但我不断收到有太多行继续的消息

这是我的代码

Sub testXLStoXML()
 sTemplateXML = _
    "<?xml version='1.0'?>" + vbNewLine + _
"<offers>" + vbNewLine + _
"   <offer>" + vbNewLine + _
"       <offer_identifier>" + vbNewLine + _
"       </offer_identifier>" + vbNewLine + _
"       <offer_title>" + vbNewLine + _
"       </offer_title>" + vbNewLine + _
"       <offer_description>" + vbNewLine + _
"       </offer_description>" + vbNewLine + _
"       <offer_featured_image>" + vbNewLine + _
"       </offer_featured_image>" + vbNewLine + _
"       <offer_cat>" + vbNewLine + _
"       </offer_cat>" + vbNewLine + _
"       <offer_location>" + vbNewLine + _
"       </offer_location>" + vbNewLine + _
"       <offer_tags>" + vbNewLine + _
"       </offer_tags>" + vbNewLine + _
"       <offer_type>" + vbNewLine + _
"       </offer_type>" + vbNewLine + _
"       <offer_start>" + vbNewLine + _
"       </offer_start>" + vbNewLine + _
"       <offer_expire>" + vbNewLine + _
"       </offer_expire>" + vbNewLine + _
"       <offer_store>" + vbNewLine + _
"       </offer_store>" + vbNewLine + _
"           <!-- store  -->" + vbNewLine + _
"           <store_title>" + vbNewLine + _
"           </store_title>" + vbNewLine + _
"           <store_letter>" + vbNewLine + _
"           </store_letter>" + vbNewLine + _
"           <store_description>" + vbNewLine + _
"           </store_description>" + vbNewLine + _
    "           <store_logo>" + vbNewLine + _
"           </store_logo>" + vbNewLine + _
    "           <store_link>" + vbNewLine + _
"           </store_link>" + vbNewLine + _
"           <store_facebook>" + vbNewLine + _
"           </store_facebook>" + vbNewLine + _
"           <store_twitter>" + vbNewLine + _
"           </store_twitter>" + vbNewLine + _
"           <store_google>" + vbNewLine + _
"           </store_google>" + vbNewLine + _
"           <!-- store  -->" + vbNewLine + _
"       <!-- DEAL RELATED -->" + vbNewLine + _
"       <deal_items>" + vbNewLine + _
"       </deal_items>" + vbNewLine + _
"       <deal_item_vouchers>" + vbNewLine + _
"       </deal_item_vouchers>" + vbNewLine + _
"       <deal_price>" + vbNewLine + _
"       </deal_price>" + vbNewLine + _
"       <deal_sale_price>" + vbNewLine + _
"       </deal_sale_price>" + vbNewLine + _
"       <deal_discount>" + vbNewLine + _
"       </deal_discount>" + vbNewLine + _
"       <deal_voucher_expire>" + vbNewLine + _
"       </deal_voucher_expire>" + vbNewLine + _
"       <deal_in_short>" + vbNewLine + _
"       </deal_in_short>" + vbNewLine + _
"       <deal_type>" + vbNewLine + _
"       </deal_type>" + vbNewLine + _
"       <deal_link>" + vbNewLine + _
"       </deal_link>" + vbNewLine + _
"   </offer>" + vbNewLine + _
"</offers>" + vbNewLine + 

有没有办法绕过限制或让这项工作?

1 个答案:

答案 0 :(得分:0)

Per Microsoft,&#34;您可以使用行继续符加入的行数有限制。此错误有以下原因和解决方案: 您的代码具有超过25条物理线路连接线连续字符,或一行中超过24个连续线路连续字符。使一些组成行在物理上更长,以减少所需的行继续符号的数量,或将构造分解为多个语句。&#34;

线条延续仅仅是为了便于阅读代码,并且必须在每个标记之后按照现在的方式进行操作