Jump to content

Saving the Excel report file in specific location


---
 Share

Recommended Posts

---

Hello everybody, 

We are trying to automate our Zeiss and we need to automatically upload our excel file to our servers. 

I can not find a way to directly save the excel files to the servers. Can anyone help me on this? 

Thanks in advance

Link to comment
Share on other sites

---

Just to add one more point, it has save automatically to the location and the excel file should close automatically as well for us to upload to our system. 

Where do I put macros to directly close the excel file? 

Thank you

Link to comment
Share on other sites

---

By default CALYPSO always outputs excel to the default results folder. This can be set via Extras > Settings > Environment > Paths > Default Path for Result Files. 

However excel output files are a bit unique in that CALYPSO doesn't has a built in function to have only excel files go to a different directory other then the default (like say a PDF). Because of this the only way to have CALYPSO move excel files to a folder other than the default results folder is to use PCM or a batch file. PCM requires you to have the license where as batch files don't.

To learn how to use batch files to move excel outputs individually have a look at CALYPSO: Batch File Automation Guide. The code will end up looking something like this but I'm sure it can be improved as well:

@ECHO OFF 

timeout /t 10

taskkill /f /im Excel.exe

timeout /t 5

move "C:\Users\Public\Documents\Zeiss\CALYPSO 8.0\workarea\results\*.xlsx" "Z:\CALYPSO results\Excel Results"

Link to comment
Share on other sites

---

Can the naming convention for the Excel output file be changed?   I'd like to add more info than just the measurement plan name _(&)_ incremental part number to the file name. 

 

 

Link to comment
Share on other sites

---

Please sign in to view this quote.

Please sign in to view this username.

 Use task scheduler and a PowerShell script to close all open instances of Excel and then move the files from the default XLS location to your servers once an hour/day/week. The script would look like this -

 

# First, stop all running Excel processes
Get-Process -Name "EXCEL" -ErrorAction SilentlyContinue | ForEach-Object { 
    try {
        Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
        Write-Host "Closed Excel process with ID $($_.Id)"
    } catch {
        Write-Warning "Failed to close Excel process with ID $($_.Id): $_"
    }
}

# Define the source directory to search for XLS files
$sourcePath = "C:\Path\To\Source\Folder"

# Define the destination directory on the server
$destinationPath = "\\ServerName\SharedFolder\Destination"

# Ensure the destination directory exists
if (!(Test-Path -Path $destinationPath)) {
    New-Item -ItemType Directory -Path $destinationPath -Force | Out-Null
}

# Get all .xls files in the source directory and its subdirectories
$xlsFiles = Get-ChildItem -Path $sourcePath -Filter *.xls -Recurse -File

foreach ($file in $xlsFiles) {
    try {
        # Construct the destination file path
        $destFile = Join-Path -Path $destinationPath -ChildPath $file.Name

        # Copy the file to the destination
        Copy-Item -Path $file.FullName -Destination $destFile -Force
        Write-Host "Copied: $($file.FullName) to $destFile"
    } catch {
        Write-Warning "Failed to copy $($file.FullName): $_"
    }
}

 

 

Edited
Link to comment
Share on other sites

 Share

×
×
  • Create New...