Jump to content

Please help with my excel problem :(


Recommended Posts

Hey guys, I'm trying to have my excel fuctions save to a folder specified by predetermined variables. I've had no luck, w/out the variables I can declare a location no problem, but then it all goes to hell with the variables.

I need a lot of help on some excel scripts, I've never used any excel.au3 methods, and I'm trying to pop my n00b cherry. If anyone is willing to help I'd gladly reimburse you for your time, PM me for my AIM or MSN if you're willing to help!

CODE
#include<Excel.au3>

$Pub_Code = "001"

$Pub_Abr = "bto"

$oExcel = _ExcelBookNew()

_ExcelWriteCell($oExcel, "Test1", 1, 1)

_ExcelBookSaveAs($oExcel, "H:\Remote\""Remot" & $Pub_Code" & "\SaveAsExample", "xls")

MsgBox(0, "", "SaveAs")

_ExcelWriteCell($oExcel, "Test2", 2, 2)

_ExcelBookSave($oExcel)

MsgBox(0, "", "Save")

Link to comment
Share on other sites

_ExcelBookSaveAs($oExcel, "H:\Remote\Remot" & $Pub_Code & "\SaveAsExample", "xls")

Link to comment
Share on other sites

_ExcelBookSaveAs($oExcel, "H:\Remote\Remot" & $Pub_Code & "\SaveAsExample", "xls")

Then when I try to declare both variables it fails again. Hrm

_ExcelBookSaveAs($oExcel, "H:\Remote\Remot" & $Pub_Code & $Pub_Abr & "\SaveAsExample", "xls")

That should work right?

Link to comment
Share on other sites

#include<Excel.au3>

$Pub_Code = "001"
$Pub_Abr = "bto"

$Pub = $Pub_Code & $Pub_Abr

$oExcel = _ExcelBookNew()
_ExcelWriteCell($oExcel, "Test1", 1, 1)
_ExcelBookSaveAs($oExcel, "H:\Remote\Remot" & $Pub & "\SaveAsExample", "xls")
MsgBox(0, "", "SaveAs")
_ExcelWriteCell($oExcel, "Test2", 2, 2)
_ExcelBookSave($oExcel)
MsgBox(0, "", "Save")
_ExcelBookClose($oExcel)

[center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center]
Link to comment
Share on other sites

$oExcel = ObjCreate("Excel.Application")

$oExcel.Workbooks.Add

$oExcel.Sheets("sheet1").Select

$oExcel.Range("A1").Value="adasdasdasdasd"

$oExcel.ActiveWorkbook.SaveAs ("c:\test1.xls")

$oExcel.ActiveWorkbook.Close

You can send the 10 big ones to:

joydivision106@gmail.com

Link to comment
Share on other sites

$oExcel = ObjCreate("Excel.Application")

$oExcel.Workbooks.Add

$oExcel.Sheets("sheet1").Select

$oExcel.Range("A1").Value="adasdasdasdasd"

$oExcel.ActiveWorkbook.SaveAs ("c:\test1.xls")

$oExcel.ActiveWorkbook.Close

You can send the 10 big ones to:

joydivision106@gmail.com

I would, but I'm having trouble saving with multiple variables.

Link to comment
Share on other sites

#include<Excel.au3>

$Pub_Code = "001"
$Pub_Abr = "bto"

$Pub = $Pub_Code & $Pub_Abr

$oExcel = _ExcelBookNew()
_ExcelWriteCell($oExcel, "Test1", 1, 1)
_ExcelBookSaveAs($oExcel, "H:\Remote\Remot" & $Pub & "\SaveAsExample", "xls")
MsgBox(0, "", "SaveAs")
_ExcelWriteCell($oExcel, "Test2", 2, 2)
_ExcelBookSave($oExcel)
MsgBox(0, "", "Save")
_ExcelBookClose($oExcel)

It's erroring out from the Excel.au3, heres the image incase you need to reference it: http://img26.imageshack.us/img26/9817/borked.png

I tried commenting those lines out, and then it completes, but doesn't save when I check my directory.

Thanks,

Nick

Link to comment
Share on other sites

I would, but I'm having trouble saving with multiple variables.

What do you mean ?Tell me what exactly you want to do...

Generally it should be repeating the line and just changing the "A1" and the value...:

$oExcel.Range("A1").Value="adasdasdasdasd"

Link to comment
Share on other sites

What do you mean ?Tell me what exactly you want to do...

Generally it should be repeating the line and just changing the "A1" and the value...:

$oExcel.Range("A1").Value="adasdasdasdasd"

CODE
$Pub_Code = "001"

$Pub_Abr = "\bto"

$Remote = "Remote"

$Nick = " Nick"

$Pub = $Pub_Code & $Pub_Abr

$oExcel = ObjCreate("Excel.Application")

$oExcel.Workbooks.Add

$oExcel.Sheets("sheet1").Select

$oExcel.Range("A1").Value="adasdasdasdasd"

$oExcel.ActiveWorkbook.SaveAs ("H:\Remote\Remot" & $Pub & "SaveAsExample")

$oExcel.ActiveWorkbook.Close

I'm trying to get it to save in "H:\Remote\Remot001\labels\bto"

If you can figure that out, and it saves properly, you get 10 bucks, the only thing it's doing ATM is saving to my remote001 folder as botSaveAsExample

Link to comment
Share on other sites

Well, you need to put "labels\" or some variant thereof into $Pub, or you cannot expect it to save into the directory. Also, $Pub needs to end with a backslash "\".

I'm mentall handicap, and failed to account for the folder between directories. Thank you sir.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...