PixelGoodies

Need help for displaying Excel format

8 posts in this topic

Good day my fellow Autoit friends.

I'm having problems getting the exact code I need for Excel. Although I have the code for Word. An image is attached how I needed my Excel to be displayed.

 

#include <Word.au3>

_WordErrorHandlerRegister()

Local $oWordApp = ObjCreate("Word.Application")
$oWordApp.Documents.add
$oWordApp.visible=1
$oWordApp.ActiveDocument.Range.ParagraphFormat.SpaceAfter = 0
$oWordApp.ActiveDocument.Sections(1).PageSetup.TopMargin = 15
$oWordApp.ActiveDocument.Sections(1).PageSetup.LeftMargin = 15
$oWordApp.ActiveDocument.Sections(1).PageSetup.RightMargin = 370
$oDoc = $oWordApp.ActiveDocument

$oWordApp.Selection.TypeText ("TRANSPORT SERVICES" & @CR & _
"Location" & @CR & _
"Tel#" & @CR & _
"Cell#" & @CR & _
"===============================================" & @CR & _
"TRIP TICKET" & @TAB & @TAB & @TAB & @TAB & "#16" & @CR & _
"===============================================" & @CR & _
"Date:" & @CR & _
"Customer:" & @CR & _
"Address:" & @CR & _
"Contact#:" & @CR & _
"Origin:" & @CR & _
"Destination:" & @CR & _
"Contracted Price (10Hrs):" & @CR & _
"===============================================" & @CR & _
"Vechicle:" & @CR & _
"Plate#:" & @CR & _
"Date Out:" & @CR & _
"Time Out:" & @CR & _
"Excess at P 100 /Hr." & @CR & _
"Date In:" & @CR & _
"Time In:" & @CR & _
"Issuer:" & @CR & _
"Total Amount:" & @CR & _
"===============================================" & @CR & _
"Provision: Cancellation of reserved trip should be 3 days" & @LF & _
"before schedule. Failure will be billed 50% of the contracted" & @LF & _
"price. Deviation from agreed destination must be cleared" & @LF & _
"with our office. In case of vehicle breakdown a rescue" & @LF & _
"vehicle will be dispatched whenever possible, otherwise" & @LF & _
"charge will be on a prorated basis." & @LF & _
"===============================================" &  @LF & @CRLF & @CRLF & _
"Name of Driver         Customer")

With $oDoc.Range.Font
    .Name = "Arial"
    .Size = 8
    .Bold = False
EndWith

Thanks in advance. ^_^

Excel.png

Share this post


Link to post
Share on other sites



Just to be sure.
The code you now have for Word should be translated to return the same result in Excel?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water,

I needed the image attached here to be displayed in Excel.

Excel.png

Share this post


Link to post
Share on other sites

As there is no variable data in the Excel sheet, wouldn't it make sense to manually create a template?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Water,

There's a variable data which I didn't include from the code. Try running my code you'll be able to understand what my problem. ^_^

Share this post


Link to post
Share on other sites

Can't run your code at the moment because I'm on a business trip right now.
If there is variable data in your template you could create the template by hand and then use _Excel_RangeReplace to replace placeholders like %date% with the current data.
So the form would be easier to maintain.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ok finally got what you meant water. Cheers!

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • LoneWolf_2106
      By LoneWolf_2106
      Hi,
      i have an error:
      ==> The requested action with this object has failed.: $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count $iRowCount = .Range(^ ERROR  
      My code is:
      $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) Sleep(1000) $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count Sleep(1000) _Excel_RangeWrite($oWorkbook_1, $oWorkbook_1.ActiveSheet,$aFileList[$i][2] , "AB3:AB"&$iRowCount) I have added some sleep because the application was crashing more often before, so i thought to slow down the code execution.
      But i didn't solve the issue.
      Has anyone an idea of what the problem might be?
      Thanks in advance.
    • water
      By water
      Extensive library to control and manipulate Microsoft Excel charts.
      Written by GreenCan and water.
      Theads: General Help & Support - Example Scripts
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort

      KNOWN BUGS (last changed: 2017-07-21)
      None. The COM error handling related bugs have been fixed.
       
    • LoneWolf_2106
      By LoneWolf_2106
      Hi,
      i have a problem with the deletion of an empty row in Excel.
      My code:
       
      If $vRow_2 = "" Then _Excel_RangeDelete($oWorkbook_1.ActiveSheet,"2", $xlShiftUp,1) EndIf I want to delete the second row. $vRow_2 is an empty cell, "A2".
      After running the code, the second row is not deleted.
      I have tried also:
       
      If $vRow_2 = Null Then _Excel_RangeDelete($oWorkbook_1.ActiveSheet,"2", $xlShiftUp,1) EndIf But it doesn't work.
      Any suggestion?
      Thanks in advance.
    • VeryGut
      By VeryGut
      I'm trying to insert the following formula in cell A2 using my script:
      =if(A1=""; "YES"; "NO")
      To my understanding, the line of code should be similar to this:
      _Excel_RangeWrite($MasterFile, Default, "=if(A1=""; "YES"; "NO")", "A2")
      However, it does not work, probably due to the multiple quotation marks that confuse the script :C
      How do I avoid this problem?
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have a question about Excel, i have to create several charts one below the other dynamically.
      I have thought to use:
       
      $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count  
      And then to use it in this way:
      $Graph_position = "=Test1!A"&$iRowCount+2&":K"&$iRowCount+24 But it doesn't work with charts.
      Does anyone have a suggestion?