<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro command to open html file using Microsoft Word in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132067#M882</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{
    // Execute preliminary commands
    KEEP SETUPSHEETS NCPROGRAM SELECTED
    TEXTINFO ACCEPT
    SPLITTER TABEXPLORE

    // Get the main project directory and construct the exact path
    STRING $mainDirectory = REPLACE(project_pathname(0), "/", "\")
    STRING $htmlFilePath = $mainDirectory + "\SetupSheets_files\project_sheets\lineup sheet.html"
    
    // Open the specified .html file if it exists
    OLE FILEACTION 'open' $htmlFilePath
}&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 05 Nov 2024 20:05:01 GMT</pubDate>
    <dc:creator>rafael.sansao</dc:creator>
    <dc:date>2024-11-05T20:05:01Z</dc:date>
    <item>
      <title>Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13131229#M877</link>
      <description>&lt;P&gt;I just posted this 2 mins ago and it got deleted by someone in the forum page, so sorry if its not as detailed cause I am furious right now about it getting deleted&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a macro that opens HTML files using Microsoft Word but get an error saying no program appears to be associated...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know the right command to open HTML files?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)

{
    // Execute preliminary commands
    KEEP SETUPSHEETS NCPROGRAM SELECTED
    TEXTINFO ACCEPT
    SPLITTER TABEXPLORE

    // Get the main project directory and construct the correct path
    STRING mainDirectory = dirname(project_pathname(0), "/")
    STRING projectSubfolder = project.Name + "" 
    STRING htmlFilePath = mainDirectory + "/" + projectSubfolder + "/SetupSheets_files/project_sheets/lineup sheet.html"
    
    // Attempt to open the specified .html file in the correct directory
    OLE FILEACTION 'open' $htmlFilePath
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_1-1730813430496.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429878iD36039DC21D25083/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_1-1730813430496.png" alt="iamcdn79_1-1730813430496.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 13:31:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13131229#M877</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-05T13:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13131712#M878</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;On Windows, right-click on the HTML file &amp;gt; Open with &amp;gt; Choose another app &amp;gt; Select Word &amp;gt; Always&lt;/P&gt;
&lt;P&gt;This will set Word as the default application for opening HTML files on your computer, and thus, the macro should work correctly.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 17:06:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13131712#M878</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-05T17:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13131756#M879</link>
      <description>&lt;P&gt;It's already set to Word&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_0-1730827422398.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429997iF652B24E645B4304/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1730827422398.png" alt="iamcdn79_0-1730827422398.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 17:25:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13131756#M879</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-05T17:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132011#M880</link>
      <description>&lt;P&gt;Something went wrong. When Word is set as the default program for opening HTML, the HTML file icon changes to the Word icon.&lt;BR /&gt;When you double-click on the HTML file, the file has to be opened with Word...&lt;/P&gt;
&lt;P&gt;Restart your computer and try again...&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;You can also change the default program through Control Panel &amp;gt; Default Programs&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 19:37:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132011#M880</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-05T19:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132051#M881</link>
      <description>&lt;P&gt;I think the directory code is incorrect. The macro code is looking into 'C:/Powermill/1792/1792 cavity/SetupSheets_files/project_sheets/lineup sheet.html' directory which doesn't exist for the lineup sheet.html file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The correct directory should be 'C:/Powermill/1792/1792 cavity/SetupSheets_files/project_sheets' to open the file called lineup sheet.html&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I change it to this code&amp;nbsp;it opens a new file explorer window of that directory showing the lineup sheet.html file but doesn't open that file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{
    // Execute preliminary commands
    KEEP SETUPSHEETS NCPROGRAM SELECTED
    TEXTINFO ACCEPT
    SPLITTER TABEXPLORE

    // Get the main project directory and construct the exact path
    STRING mainDirectory = dirname(project_pathname(0), "/")
    STRING projectSubfolder = project.Name
    STRING htmlFilePath = mainDirectory + "/" + projectSubfolder + "/SetupSheets_files/project_sheets"
    
    // Open the specified .html file if it exists
    
        OLE FILEACTION 'open' $htmlFilePath
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 19:55:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132051#M881</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-05T19:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132067#M882</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{
    // Execute preliminary commands
    KEEP SETUPSHEETS NCPROGRAM SELECTED
    TEXTINFO ACCEPT
    SPLITTER TABEXPLORE

    // Get the main project directory and construct the exact path
    STRING $mainDirectory = REPLACE(project_pathname(0), "/", "\")
    STRING $htmlFilePath = $mainDirectory + "\SetupSheets_files\project_sheets\lineup sheet.html"
    
    // Open the specified .html file if it exists
    OLE FILEACTION 'open' $htmlFilePath
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Nov 2024 20:05:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132067#M882</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-05T20:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132085#M883</link>
      <description>&lt;P&gt;Same error as before because I think its looking in the wrong dir.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The correct dir should be 'C:\Powermill\1792\1792 cavity\SetupSheets_files\project_sheets' but the error code is showing dir called 'C:\Powermill\1792\1792&lt;BR /&gt;cavity\SetupSheets_files\project_sheets\lineup sheet.html' which doesn't exist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_1-1730837385732.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1430070iCB1A654C14D5BB63/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_1-1730837385732.png" alt="iamcdn79_1-1730837385732.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the dir it should be pointing too for the file called lineup sheet.html&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_0-1730837319898.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1430067iF21C024467DA8114/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1730837319898.png" alt="iamcdn79_0-1730837319898.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 20:12:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132085#M883</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-05T20:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132617#M884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3960527"&gt;@iamcdn79&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I tested your macro and it's working well when opening an HTML file by Excel.&lt;/P&gt;&lt;P&gt;in my opinion, the macro is OK, the problem is Word not suitable to open HTML.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 02:16:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13132617#M884</guid>
      <dc:creator>nguyenthinhvt95</dc:creator>
      <dc:date>2024-11-06T02:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133449#M885</link>
      <description>&lt;P&gt;If you change it to Word instead of Excel to open HTML does it still work?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 11:38:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133449#M885</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-06T11:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133520#M886</link>
      <description>&lt;P&gt;My macro doesn't even work for Excel files when I change the extension to .xlsx and Excel is already the default pgm for that extension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_1-1730895898759.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1430387iD86450B7768D98B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_1-1730895898759.png" alt="iamcdn79_1-1730895898759.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_0-1730895802466.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1430386i5A7AD5FAE65662B5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1730895802466.png" alt="iamcdn79_0-1730895802466.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 12:25:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133520#M886</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-06T12:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133707#M887</link>
      <description>&lt;P&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{
    // Execute preliminary commands
    KEEP SETUPSHEETS NCPROGRAM SELECTED
    TEXTINFO ACCEPT
    SPLITTER TABEXPLORE

    // Get the main project directory and construct the exact path
    STRING $mainDirectory = REPLACE(project_pathname(0), "/", "\")
    STRING $htmlFilePath = $mainDirectory + "\SetupSheets_files\project_sheets\lineup sheet.html"
    IF NOT file_exists($htmlFilePath) {
		MESSAGE WARN "File not exists"
		MACRO ABORT
	} ELSE {
		STRING $cmd_content = "@echo off" + CRLF + 'start "" "' + $htmlFilePath + '"'
		STRING $cmd_path = $mainDirectory + "\run.cmd"
		FILE OPEN $cmd_path FOR WRITE AS cmd
		FILE WRITE $cmd_content TO cmd
		FILE CLOSE cmd
		OLE FILEACTION 'open' $cmd_path
		WAIT 1
		FILE DELETE $cmd_path
	}
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 06 Nov 2024 13:53:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133707#M887</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-06T13:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133728#M888</link>
      <description>&lt;P&gt;Yes! that opens, but i get an error on line&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;FILE DELETE $cmd_path​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after the file opens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it trying to delete the lineup sheet.html file or that directory that it exists?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_0-1730901757860.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1430447i71EDBA4FEEA8BDEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1730901757860.png" alt="iamcdn79_0-1730901757860.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Removing that line seems to run without issues.&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 06 Nov 2024 14:05:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133728#M888</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-06T14:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133845#M889</link>
      <description>&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{
    // Execute preliminary commands
    KEEP SETUPSHEETS NCPROGRAM SELECTED
    TEXTINFO ACCEPT
    SPLITTER TABEXPLORE

    // Get the main project directory and construct the exact path
    STRING $mainDirectory = REPLACE(project_pathname(0), "/", "\")
    STRING $htmlFilePath = $mainDirectory + "\SetupSheets_files\project_sheets\lineup sheet.html"
    IF NOT file_exists($htmlFilePath) {
		MESSAGE WARN "File not exists"
		MACRO ABORT
	} ELSE {
		STRING $cmd_content = "@echo off" + CRLF + 'start "" "' + $htmlFilePath + '"'
		STRING $cmd_path = $mainDirectory + "\run.cmd"
		FILE OPEN $cmd_path FOR WRITE AS cmd
		FILE WRITE $cmd_content TO cmd
		FILE CLOSE cmd
		OLE FILEACTION 'open' $cmd_path
		WAIT 1
		DELETE FILE $cmd_path
	}
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 06 Nov 2024 14:48:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133845#M889</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-06T14:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133868#M890</link>
      <description>&lt;P&gt;Here is the complete code&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{

    IF ($powermill.Status.MultipleSelection.First) OR ($powermill.Status.MultipleSelection.Total == 0) {

    // Execute preliminary commands
    KEEP SETUPSHEETS NCPROGRAM SELECTED
    TEXTINFO ACCEPT
    SPLITTER TABEXPLORE
}

    // Get the main project directory and construct the exact path
    STRING $mainDirectory = REPLACE(project_pathname(0), "/", "\")
    STRING $htmlFilePath = $mainDirectory + "\SetupSheets_files\project_sheets\lineup sheet.html"
    IF NOT file_exists($htmlFilePath) {
		MESSAGE WARN "File not exists"
		MACRO ABORT
	} ELSE {
		STRING $cmd_content = "@echo off" + CRLF + 'start "" "' + $htmlFilePath + '"'
		STRING $cmd_path = $mainDirectory + "\run.cmd"
		FILE OPEN $cmd_path FOR WRITE AS cmd
		FILE WRITE $cmd_content TO cmd
		FILE CLOSE cmd

         //Check if it is the last selection or if there are no items selected
        IF ($powermill.Status.MultipleSelection.Last) OR ($powermill.Status.MultipleSelection.Total == 0) {
            OLE FILEACTION 'open' $cmd_path
            WAIT 1
            DELETE FILE $cmd_path
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to close the microsoft word lineup sheet.html file if it is already one when running this code?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 15:00:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13133868#M890</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-06T15:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13134749#M891</link>
      <description>&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;You can try using Powershell to close the file, but you will need to select Powershell as the default program for executing ps1 files.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;This will only work if your computer's group policy allows scripts to be executed.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{
    // Get the main project directory and construct the exact path
    STRING $mainDirectory = REPLACE(project_pathname(0), "/", "\")
    STRING $htmlFilePath = $mainDirectory + "\SetupSheets_files\project_sheets\lineup sheet.html"
	
    IF ($powermill.Status.MultipleSelection.First) OR ($powermill.Status.MultipleSelection.Total == 0) {
		IF file_exists($htmlFilePath) {
			STRING $char = "$"
			STRING $ps1_content = $char + 'path = "' + $htmlFilePath + '"'
			$ps1_content = $ps1_content + CRLF + $char + 'word = [Runtime.InteropServices.Marshal]::GetActiveObject("Word.Application")'
			$ps1_content = $ps1_content + CRLF + 'foreach (' + $char + 'doc in ' + $char + 'word.Documents) {'
			$ps1_content = $ps1_content + CRLF + '    if (' + $char + 'doc.FullName -eq ' + $char + 'path) {'
			$ps1_content = $ps1_content + CRLF + '        ' + $char + 'doc.Close()'
			$ps1_content = $ps1_content + CRLF + '        break'
			$ps1_content = $ps1_content + CRLF + '    }'
			$ps1_content = $ps1_content + CRLF + '}'
			STRING $ps1_path = $mainDirectory + "\run.ps1"
			FILE OPEN $ps1_path FOR WRITE AS cmd
			FILE WRITE $ps1_content TO cmd
			FILE CLOSE cmd
            OLE FILEACTION 'open' $ps1_path
            WAIT 2
            DELETE FILE $ps1_path
		}
		// Execute preliminary commands
		KEEP SETUPSHEETS NCPROGRAM SELECTED
		TEXTINFO ACCEPT
		SPLITTER TABEXPLORE
	}

    IF NOT file_exists($htmlFilePath) {
		MESSAGE WARN "File not exists"
		MACRO ABORT
	} ELSE {
		STRING $cmd_content = "@echo off" + CRLF + 'start "" "' + $htmlFilePath + '"'
		STRING $cmd_path = $mainDirectory + "\run.cmd"
		FILE OPEN $cmd_path FOR WRITE AS cmd
		FILE WRITE $cmd_content TO cmd
		FILE CLOSE cmd

         //Check if it is the last selection or if there are no items selected
        IF ($powermill.Status.MultipleSelection.Last) OR ($powermill.Status.MultipleSelection.Total == 0) {
            OLE FILEACTION 'open' $cmd_path
            WAIT 1
            DELETE FILE $cmd_path
        }
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 21:43:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13134749#M891</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-06T21:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136131#M892</link>
      <description>&lt;P&gt;So I did all that and I don't get any errors but it doesan't close the word file linup sheet.html when it is open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think it could because when I always close it manually its asking me if it needs to be saved or not due to a macro I have which runs and changes values automatically everytime it opens that particular file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to add a no to not to save the file then close it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_0-1730981777992.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1430985i16EC0A2B1EAD66D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1730981777992.png" alt="iamcdn79_0-1730981777992.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 12:17:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136131#M892</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-07T12:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136145#M893</link>
      <description>&lt;P&gt;Replace:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;$ps1_content = $ps1_content + CRLF + '        ' + $char + 'doc.Close()'&lt;/LI-CODE&gt;
&lt;P&gt;By:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;$ps1_content = $ps1_content + CRLF + '        ' + $char + 'doc.Close(0)'&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Nov 2024 12:23:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136145#M893</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-07T12:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136161#M894</link>
      <description>&lt;P&gt;No change&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 12:30:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136161#M894</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-07T12:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136303#M895</link>
      <description>&lt;LI-CODE lang="csharp"&gt;FUNCTION Main (STRING $Selected_NCProgram)
{
    // Get the main project directory and construct the exact path
    STRING $mainDirectory = REPLACE(project_pathname(0), "/", "\")
    STRING $htmlFilePath = $mainDirectory + "\SetupSheets_files\project_sheets\lineup sheet.html"
	
    IF ($powermill.Status.MultipleSelection.First) OR ($powermill.Status.MultipleSelection.Total == 0) {
		IF file_exists($htmlFilePath) {
			STRING $char = "$"
			STRING $ps1_content = $char + 'path = "' + $htmlFilePath + '"'
			$ps1_content = $ps1_content + CRLF + $char + 'word = [Runtime.InteropServices.Marshal]::GetActiveObject("Word.Application")'
			$ps1_content = $ps1_content + CRLF + 'foreach (' + $char + 'doc in ' + $char + 'word.Documents) {'
			$ps1_content = $ps1_content + CRLF + '    if (' + $char + 'doc.FullName -eq ' + $char + 'path) {'
			$ps1_content = $ps1_content + CRLF + '        ' + $char + 'doc.Close(0)'
			$ps1_content = $ps1_content + CRLF + '        break'
			$ps1_content = $ps1_content + CRLF + '    }'
			$ps1_content = $ps1_content + CRLF + '}'
			STRING $ps1_path = $mainDirectory + "\run.ps1"
			FILE OPEN $ps1_path FOR WRITE AS cmd
			FILE WRITE $ps1_content TO cmd
			FILE CLOSE cmd
			OLE FILEACTION 'open' $ps1_path
			STRING $cmd_content = "@echo off" + CRLF + 'powershell -ExecutionPolicy Bypass -File "' + $ps1_path + '"'
			STRING $cmd_path = $mainDirectory + "\run.cmd"
			FILE OPEN $cmd_path FOR WRITE AS cmd
			FILE WRITE $cmd_content TO cmd
			FILE CLOSE cmd
			OLE FILEACTION 'open' $cmd_path
			WAIT 2
			DELETE FILE $cmd_path
			DELETE FILE $ps1_path
		}
		// Execute preliminary commands
		KEEP SETUPSHEETS NCPROGRAM SELECTED
		TEXTINFO ACCEPT
		SPLITTER TABEXPLORE
	}

    IF NOT file_exists($htmlFilePath) {
		MESSAGE WARN "File not exists"
		MACRO ABORT
	} ELSE {
		STRING $cmd_content = "@echo off" + CRLF + 'start "" "' + $htmlFilePath + '"'
		STRING $cmd_path = $mainDirectory + "\run.cmd"
		FILE OPEN $cmd_path FOR WRITE AS cmd
		FILE WRITE $cmd_content TO cmd
		FILE CLOSE cmd

         //Check if it is the last selection or if there are no items selected
        IF ($powermill.Status.MultipleSelection.Last) OR ($powermill.Status.MultipleSelection.Total == 0) {
            OLE FILEACTION 'open' $cmd_path
            WAIT 1
            DELETE FILE $cmd_path
        }
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Nov 2024 13:46:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136303#M895</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2024-11-07T13:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro command to open html file using Microsoft Word</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136572#M896</link>
      <description>&lt;P&gt;No go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would a lockfile be preventing it from closing? When I have the file open there is a hidden file in the dir called "~$nep sheet.html"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="iamcdn79_1-1730994116818.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1431089i721751F95E21F4AD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_1-1730994116818.png" alt="iamcdn79_1-1730994116818.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 15:42:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-command-to-open-html-file-using-microsoft-word/m-p/13136572#M896</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-11-07T15:42:01Z</dc:date>
    </item>
  </channel>
</rss>

