Macro code produces error

Version: 2004
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

Hi everyone, <br><br>When I test the macro code below on Word 2004, I get the following error: <br><br>Compile error: user-defined type not defined <br><br>This only happens when I run the code on my mac. When I test it on a PC with Word 2007, it works fine. <br><br>I wondered if someone could run it for me and tell me if you get the same error? <br><br>Appreciate any assistance. <br><br>Sub GetImage() <br><br>    Dim dlg As Office.FileDialog <br>
&nbsp;&nbsp;&nbsp;&nbsp;Dim strFilePath As String <br><br>    Set dlg = Application.FileDialog(msoFileDialogFilePicker) <br><br>    With dlg <br>
&nbsp;&nbsp;&nbsp;&nbsp;.AllowMultiSelect = False       'Make single selection only <br>
&nbsp;&nbsp;&nbsp;&nbsp;If .Show() <> 0 Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;strFilePath = .SelectedItems(1) <br>
&nbsp;&nbsp;&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;End With <br><br>        Selection.InlineShapes.AddPicture FileName:= _ <br>
&nbsp;&nbsp;&nbsp;&nbsp;strFilePath, LinkToFile:=False, _ <br>
&nbsp;&nbsp;&nbsp;&nbsp;SaveWithDocument:=True <br><br>End Sub
0
gwh
1/8/2010 3:53:18 AM
mac.office.word 1676 articles. 1 followers. Follow

8 Replies
1900 Views

Similar Articles

[PageSpeed] 6

I have the same problem here, and it's because the Offce.FileDialog 
object is simply not available on Mac VBA. "Word 2004" sounds as if it 
ought to be similar to "Word 2003," which has that object, but in fact 
it's more like Word 2000 as far as VBA is concerned.

So I think you'll need to change your code to work with

Dim dlg As Word.Dialog
Set dlg = Application.Dialogs(wdDialogInsertPicture)

e.g. something like

Sub GetImage()

Dim dlg As Word.Dialog

Set dlg = Application.Dialogs(wdDialogInsertPicture)
With dlg
     .linktofile = False
     ' .SaveWithDocument not available on Mac
     ' .SaveWithDocument = True
     If .Display() <> 0 Then
        Selection.InlineShapes.AddPicture FileName:= _
     .Name, linktofile:=False, _
     SaveWithDocument:=True
     End If
End With

End Sub


Peter Jamieson

http://tips.pjmsn.me.uk

On 08/01/2010 03:53, gwh@officeformac.com wrote:
> Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel
> Hi everyone,
>
> When I test the macro code below on Word 2004, I get the following error:
>
> Compile error: user-defined type not defined
>
> This only happens when I run the code on my mac. When I test it on a PC
> with Word 2007, it works fine.
>
> I wondered if someone could run it for me and tell me if you get the
> same error?
>
> Appreciate any assistance.
>
> Sub GetImage()
>
> Dim dlg As Office.FileDialog
> Dim strFilePath As String
>
> Set dlg = Application.FileDialog(msoFileDialogFilePicker)
>
> With dlg
> .AllowMultiSelect = False 'Make single selection only
> If .Show() <> 0 Then
> strFilePath = .SelectedItems(1)
> End If
> End With
>
> Selection.InlineShapes.AddPicture FileName:= _
> strFilePath, LinkToFile:=False, _
> SaveWithDocument:=True
>
> End Sub
0
Peter
1/9/2010 10:31:03 AM
Thanks for the reply, <br><br>I tried your code but received the following error on testing: <br><br>Run-time error '4605' <br>
This command is not available. <br><br>Do you know what this is about?
0
gwh
1/10/2010 9:50:34 AM
It probably means that the command on the line of code where the macro 
stopped is not available.  :-)  Check out that specific line of code to 
see what might be wrong.



--rms

www.rmschneider.com




On 10/01/10 09:50, gwh@officeformac.com wrote:
> Thanks for the reply,
>
> I tried your code but received the following error on testing:
>
> Run-time error '4605'
> This command is not available.
>
> Do you know what this is about?
0
Rob
1/10/2010 10:21:03 AM
It can help if you can click the "Debug" button (if you see one) in the 
error dialog box and see which line caused the error. Or you can use 
View->Toolbars to enable the Debug toolbar and step through the code 
line-by-line to identify the problem code.

Peter Jamieson

http://tips.pjmsn.me.uk

On 10/01/2010 09:50, gwh@officeformac.com wrote:
> Thanks for the reply,
>
> I tried your code but received the following error on testing:
>
> Run-time error '4605'
> This command is not available.
>
> Do you know what this is about?
0
Peter
1/10/2010 11:07:41 AM
When I press the debug button, the following line is highlighted: <br><br>Set dlg = Application.Dialogs(wdDialogInsertPicture) <br><br>I'm not sure what's wrong with it.
0
gwh
1/10/2010 8:53:24 PM
One reason you might get that error is if the document is protected for 
forms. There could be other reasons but I don't know what they might be.

Peter Jamieson

http://tips.pjmsn.me.uk

On 10/01/2010 20:53, gwh@officeformac.com wrote:
> When I press the debug button, the following line is highlighted:
>
> Set dlg = Application.Dialogs(wdDialogInsertPicture)
>
> I'm not sure what's wrong with it.
0
Peter
1/11/2010 12:13:34 AM
Yes my document is protected for forms. Is there a workaround as the code needs to work with the locked form.
0
gwh
1/11/2010 5:24:07 AM
As far as I know the only options are to unprotect the form, do the 
insert, then re-protect

(surround your macro with

ActiveDocument.Unprotect Password:="YourPassword"

and

ActiveDocument.Protect _
   Type:=wdAllowOnlyFormFields, _
   NoReset:=True, _
   Password:="YourPassword"

which has the disadvantage of embedding the password in the VBA)

or if your layout allows it, create a separate Word section and leave it 
unprotected, which has the disadvantage that there is no restriction on 
what the user can insert.

Peter Jamieson

http://tips.pjmsn.me.uk

On 11/01/2010 05:24, gwh@officeformac.com wrote:
> Yes my document is protected for forms. Is there a workaround as the
> code needs to work with the locked form.
0
Peter
1/11/2010 11:51:58 AM
Reply:

Similar Artilces:

"Memory" errors in Publisher 2002
A customer reports that Publisher 2002 was running fine. Now the program will open, but whenever you do anything (open a file, click Help/About, etc.) you get an error message: The instruction at "0x00000000" referenced memory at "0x00000000". The memory could not be "read." The hex numbers change. I can find nothing about this specific behavior in the MS knowledge base. I removed and reinstalled the product but to no avail. Any ideas? Thanks Mike Possibly corrupt printer driver. Try shorting the name of the printer to 8 characters. If that does no...

how to get rid of errors? #2
Thanks for the input, but actually I was more concerned about gettin rid of all error messages when the file loads up. It looks like yo gave me a cool utility, but I am not too concerned about fixing th links. Is there a way to ignore all messages that pop up when i load my exce sheet? regardless of what it is? Thank -- Jon ----------------------------------------------------------------------- Jonx's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1317 View this thread: http://www.excelforum.com/showthread.php?threadid=26148 Think deleting all the "pha...

Send Receive Errors
If you have been getting regular Send / Recieve error messages...eg. "can't connect to server" etc. in XP...and have been bashing your head against a wall tinkering with NAV and other possible fixes, try this simple solution... add a period (dot) to the end of your mail server names in the account settings for each mail account you have. For example: change mail.servername.com to mail.servername.com. I read this on another forum, tried it, and I have not had an error message in the last 5-6 Send/Receive cycles (touch wood), when I was getting them each time prior to th...

outloor error when first open outlook
when I open Outlook I get this error... Ther ewas a problem reading one or more of your reminders. some reminders may not appear. cannot locate reccurance information for this appointment. please HELP! *CS lpgtweety@yahoo.com ...

Linked Objects Error
I have Excel spreadsheets which I link certain sections to various Publisher files. When I open a few (not all) of the Publisher files and the update links begins, I receive an error: "A document with the name ??????? (Excel spreadsheet name is shown) is already open. You can not open two documents with the same name, even if the documents are in different folders. To open the second document, either close the document that is currently open, or rename one of the documents." This error occurs even though there is only one occurence of the Excel document open. I can cl...

Frx: linked data worksheet summing error
We use linked data worksheets for some of our reporting. The column format displays both current period and YTD. The YTD column is not calculating the correct amounts from the worksheet. For example, if we were in period 12, it would sum the YTD column as follows. period 1: add 12x period 2: add 11x period 3: add 10x period 4: add 9x ....and so forth period 12: add 1x Obviously, this gives us a huge error in the ytd column. Anyone have an idea why this is occurring? We are using the /cpo format for the linked worksheet. Thanks ...

Error Delegating Administrator Rights & Removing SID
I have recently taken over for a NetAdmin who I believe deleted the account of the previous NetAdmin rather than disabling it. Consequently ... When attempting to use the Exchange Administration delegation wizard to add or remove a group or a user to the Organization level, I receive the following error: Failed to grant permission from company\Exchange_administrators on this object:/dc=net/dc=company/cn=configuration Subsequently clicking the [NEXT] button yields: The delegation wizard could not grant/change permissions for company\exchange_administrators I would like to remov...

Big Error
An update query updated a large number of field values in the wrong field. It added the value YED-14- to the left of the existing values. Is there a way to remove the YED-14- without doing it manually or requesting IT to restore the database from backups, and return the values to there original values. This will really save us embarrasement. Thank you ever-so-much. On Sat, 8 Mar 2008 09:26:00 -0800, PA <PA@discussions.microsoft.com> wrote: >An update query updated a large number of field values in the wrong field. >It added the value YED-14- to the left of the existing value...

The macro cannot be found
I have problem when I wanna open Excel Files. The error message is like this : The macro "C:\Windows\Application Data\Microsoft\Excel\XLSTART\Book1'!Test5' cannot be found. Please help me. Thanks. Anathapindika. Does this happen when you're starting excel or does it happen when you do File|Open from within xl? Does it happen when you double click on a file (in windows explorer) with xl open or when excel is closed? I'm gonna guess that it happens when you start excel (maybe by double clicking on a file in explorer). Excel loads files in your XLStart folder and addi...

Bob? Code to Post?
Thanks Bob! Could you put the code in a reply to this message! Also what does Dim cellvalue do? Thanks Nick This is my entire module reposted. Should work, as far as I can tell. It's reporting the correct values on lose. (What was happening, was, when it would put down the "Lose", the value of B2 would recalculate, and no longer be 7.) And FYI, Dim cellvalue defines 'cellvalue' as a variable which I can pass data to. I use it to define what cell is currently being used. START OF MODULE (Insert New Module, Paste from the top) Dim cellvalue Sub Craps() 'Excel...

"Correct Version" error b.s.
I have the Teacher and Student version of 2004. When I install, the Microsoft Component Plugin info shows V11.2.2 (the applications all show 11.2.0--see end of msg). Autoupdating downloads the update 11.2.5 and I get the "can't find correct version..." you all know the bull. This is incredibly frustrating that security on so vulnerable a product is so impossible to achieve! I've followed the instructions on the mvp site as advised for removing and cleaning prior to a clean reinstall, and didn't make one iota of difference. I followed each step religiously, emptying the...

Item Search Error
Hi I'm running MS POS, when I type / scan an item in the serch box provided at the top, it keeps searching by Customer name and returns " the customer was not found". I really want it to search by Item #. Is there something I am doing wrong or is it a bug in the system? Thanks In MS POS (not RMS) a scan and a search will behave a bit differently. If your scanner isn't setup properly you could get some mixed results. First, about scanners... Your scanner needs to be configured as a device for the register. Unlike RMS even a keyboard wedge device needs to be setu...

how do I stop error message
each time I open any Ms doc I receive an error box saying office application version does not match Does this article help? Error message when you start a 2007 Office program on a computer that is running Outlook 2007 with Business Contact Manager: "Office application version does not match" http://support.microsoft.com/kb/935569/ -- Mary Sauer http://msauer.mvps.org/ "Christine" <Christine@discussions.microsoft.com> wrote in message news:9D6F5DEB-26B1-4801-B160-BA8B9A6B2312@microsoft.com... > each time I open any Ms doc I receive an error box saying office...

#value! Error
From a drop down list of 15 names in A2, B1 returns a value of 1-1 depending on which name selected. The idea is to show in column D the names of upto 24 players, the nam chosen in A2 has played. I use the following formula. ( a nested IF only allows 7 options??) =IF($B$1=1,I2,0)+IF($B$1=2,L2,0)+IF($B$1=3,O2,0)+IF($B$1=4,R2,0)+IF($B$1=5,U2,0)+IF($B$1=6,X2,0)+IF($B$1=7,AA2,0)+IF($B$1=8,AD2,0 & so on to +IF($B$1=15,AW2,0) This formula is repeated 24 times D4 through D27 to return text fro cell reference I2, L2, O2 & so on. It returns always returns #value! if I change text to numbers i...

reseting toolbars incase of fatal error
Afternoon All: I am working on a program for internal distribution. When this progra opens (through excel) the vbasic code disables all tool bars includin the Menu bar. Every step of the way, the user has an option t continue or abort. If the process is continued, when finished th toolbars will be enabled. If it is aborted, the code enables the too bars and closes (w/out saving) workbook. I know...as sure as the su rises in the east, that someone is going to power off, or ctrl al delete to get out of this operation. Is there a way, that excel ca reset to default (re: enable toolbars). ...

How to fix error "Unable to load client print control" ?
We get an error when clicking the printer icon on a report generated through SQL Reporting Services via GP. The error message is "Unable to load client print control" The report data does output correctly in IE, however, when we click on the printer icon to print the report we get the above error. Previously we never used to get this error. We have made sure the ActiveX components have been installed on all workstations that allow this printing functionality. Does anyone have any ideas how to resolve this error in SQL Reporting Services? Thanks DGP, http://support.microso...

Outlook 2002 error #3
I get a "The Operation Failed" message when I attempt to "Send/Receive". I verified account was set up correctly by using the "Test Account Settings" See if http://support.microsoft.com/default.aspx?scid=kb;en-us;312354 helps. -- Jeff Stephenson Outlook Development This posting is provided "AS IS" with no warranties, and confers no rights "Tony" <anonymous@discussions.microsoft.com> wrote in message news:057a01c3b9f9$15ff8b50$a301280a@phx.gbl... > I get a "The Operation Failed" message when I attempt to > "Send...

Coding for future month results
Below is my current code for October's reporting. It is a project form showing planned progress (OctPlan), actual progress (OctAct) and via the attached code, an indicator and color for October (OctInd). This code works great (thanks to the help on here) However, my form shows all 12 months, so the code currently causes future months to indicate red. Is there a an If then type statement that I can place this current code into that will basically say If OctAct is null then OctInd = N/A? or is null ruined based on the the code? Is there some other procedure I can try? I've ...

Inventory Management Category code
Hi, The Item Category codes in Inventory management are very primitive and require a lot of changes. Inventory Setup: There should be a provision for uploading Item Category codes. This is useful for companies handling huge inventory and different types of inventories. There should be a look up for finding the correct category code. Item Master: The category codes displayed in Item master only display the code. Description is not displayed. This becomes quite difficult for users to check on category codes with only codes displayed. The current lookup available should also include sear...

MAPI Errors
I have started to get errors when I try and send an office 2k document from its file:send:mail recipient menu. I get similar errors from all applications. From word I get; "The operation failed due to network or other communication problems. Check your connections and try again." Followed by; "Word couldn't send mail because of MAPI failure: "Unspecified error". From Excel I get; "The operation failed due to network or other communication problems. Check your connections and try again." Followed by "General mail failure. Quit Microsoft Excel...

Error Event ID 8277
I have been getting this error number and I have look in the knowlage base and google and I cannot find any help. Any ideas on this one? Error while getting sorted message table for duplicate message deletion on virtual machine PROLINEXCH. The error number is 0x80004005. Alert in Event log: Application Type: Error Date: 4/13/2004 Time: 03:00 AM Source: MSExchangeFBPublish Category: (1): General Event ID: 8277 User: Thanks for any help!!!! What version and SP level of Exchange? Rick wrote: > I have been getting this error number and I have look in t...

great plains should allow negative wages to fix payroll errors
---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=57737c6d-2bb2-49b6-808d-b1673ae5f563&dg=microsoft.public.greatplains ...

SQL error installing POS 2009
I am installing on a laptop for back office functionality. During the installation I am getting this: Cannot connect to WMI provider. You do not have permission or the Server is unreachable. Note that you can only manage SQL server 2005 or later Servers with SQL Server Configuration Manager. Invalid namespace [0x8004100e] No Ideas? "Bill Cunningham" wrote: > I am installing on a laptop for back office functionality. During the > installation I am getting this: > > Cannot connect to WMI provider. You do not have permission or the > Server is u...

Hyperlink Coding (2000 vs. 2003)
Hi all, I created a form to hold hyperlinks to pdf and jpg files. The form has three fields, all with the hyperlink data type. I then created a command button that when clicked, allows the user to navigate to a file, click open and then set the value of the field to {FieldName}#{FieldName} so that Access will recognize the hyperlink as both display text and address. However, Access 2000 only views the display text and ignores the address. Any idea as to why Access 2000 only sees one part of the hyperlink? Also, how would I go about fixing it, if I'm using Access 2003 to c...

OL03 and network errors quesiton
Is it possible to set OL to be silent in the presence of network errors (and just retry until it works), rather than bringing up the "send/receive progress" and/or the "enter network password" dialogs? As it is, it's not only annoying, but OL halts processing on all inboxes (causing the server-side to fill-up) until the dialogs are manually dismissed, assuming the computer is even attended. thanks, mike Mike <vimakefile@yahoo.com> wrote: > Is it possible to set OL to be silent in the presence of network > errors (and just retry until it works), r...