Jump to content
Sign in to follow this  

Use a variable for a parameter in _ExcelReadArray

Recommended Posts

I was hoping someone has figured this out.  I am using an Excel spreadsheet v 2012 to organize a list of email addresses for notification reciprients.  It is organized by location via column header. What I am trying to do is create a part of a script that can read from an ini file the column to start in and read those cells to an array that the script will use to address a SMTP email.   Here is what I have so far

#Include <file.au3>
#include <INetSmtpMailCom.au3>
#include <Array.au3>
#include <Excel.au3>
$inifile = FileOpen("C:gpalertgpsetup.ini", 0)
$L = FileReadLine($inifile, 7)
$oExcel = _ExcelBookOpen("c:gpalertGP Notification List.xlsx", 0)
$aArray = _ExcelReadArray($oExcel, 3, $L, 7, 1, 1) ;Direction is Vertical
$s_ToAddress = _ArrayToString($aArray, "; ", 1, 7)
  _ExcelBookClose($oExcel, 0, 0)

; msgbox below is just for testing

 MsgBox(0, "Test Excel",  $s_ToAddress)

Any help other method or work around would be most helpful.


Edited by WilliamP

Share this post

Link to post
Share on other sites

Ok this was an interesting fix.  Nothing wrong with my code,  just discovered that for some reason when I place a space before the line in my .ini file that $L is pulled from, it worked.  The function  _NetSmtpMailCom (wonderful function by the way, great praises to Jos who created it) for some reason didn't interpret the variable $L to be, in this case, 1 even though the MsgBox displayed it, until the space was added.  I am thinking something in the way   $L = FileReadLine($inifile, 7) parsed the data in the.ini file without the preceding space placed in the line.

I hope this helps someone that runs into a simular issue.

Happy scripting.

Share this post

Link to post
Share on other sites

Why aren't you using the INI functions to read and write to your INI file instead of fileread*?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post

Link to post
Share on other sites

Err INI functions????   I'll have to check into those.  I've been scripting for a while but lately I have been getting into projects that are getting increasingly complex.

Thanks for the help.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...